I tried to block some email addresses from spammers, but this setup doesn't seem to have any effect:

smtpd_recipient_restrictions =
    check_recipient_access hash:/etc/postfix/bad_recipients,

The emails are still forwarded. Here is an example of the bad_recipients file I have:

# When updating, make sure to run this command once:
#    postmap hash:/etc/postfix/bad_recipients

spammer@example.com REJECT

When I do a mail to that email address, it still gets forwarded.

alexis $ mail -s "Verify block" spammer@example.com

Not much of interest here.

When I look at the logs I see something like this:

Mar 5 20:02:37 do postfix/smtp[8882]: E827740ADA: to=, relay=mail.example.com[]:25, delay=2.3, delays=0.03/0.01/1.8/0.41, dsn=5.7.1, status=bounced (host mail.example.com[] said: 550 5.7.1 No such user! (in reply to RCPT TO command))

Note: I edited the domain name and IP address.

The relaying to the external source clearly shows that my smtpd_recipient_restrictions settings did not block anything. I'm thinking that either it only accepts domains (although I think the doc examples here say otherwise) or I have something else that tells postfix to ignore my list of recipient restrictions. Do you know how to make this feature work?


Okay! I found the answer.

The fact is that it works only if the user attempts to send an email using SMTP. So when using tools such as sendmail or mail, postfix ignores that entry because there is not RCPT TO <address> to check. This is a problem for some of my tools, fortunately, the one I want to block at the moment uses SMTP so I'm covered. Only I can't test whether it works using the mail command line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.