I have a catch-all email address for my domain, however I want to block certain addresses from receiving mail. Before, I was doing it like this:
:0
* ^(X-Original-To): [email protected]
/dev/null
This works fine, however, the email is silently disregarded. I want a bounce mail to be sent back to the sender so that they know that it's being rejected. I used similar code to this answer:
:0
* ^(X-Original-To): [email protected]
{ EXITCODE=67 HOST= }
However, now the emails are being delivered and no bounce mail is being sent.
Besides the obvious typo in your attempt, your example works if I put the recipe in my personal
.procmailrc
.Here's a quick demo on Ubuntu in a fresh Docker container where I installed Postfix, Procmail, and Netcat, and created a user account for myself:
However, the same recipe in
/etc/procmailrc
causes the message to be delivered anyway; basically,HOST=
says skip the current recipe file, but in/etc/procmailrc
, that means stop reading this file and proceed to deliver to the user.I can only speculate that that is the actual problem you are experiencing. If you have more details, please edit your question to provide them.
As an aside, the parentheses are superfluous, and the dot should be escaped.
If you enable verbose logging with
VERBOSE=yes
you'll see that Procmail actually assignsHOST=}
which is not really what I would expect, but it works (as long as yourHOST
isn't really named}
!)Notice also how the log file shows the incoming message being discarded, and then a bounce message being delivered to me (as I was the sender as well as the recipient). However, the generated bounce message includes text which (obscurely) reveals that the recipient address actually does exist after all:
You probably have to be fairly intimately familiar with Postfix bounce messages to understand exactly what this means; it basically says that it expanded
tripleee
to a fully expanded email address with the domain name included, and then delivering to that produced the error message to the right of the colon. (For better or for worse, Sendmail's bounce messages are more obscure still; but the real pro of unintelligible error messages, as always, is Microsoft.)