Linux – How to reject email sent to root@thedomain.tld from external sources in postfix

configurationemaillinuxpostfix

I have a postfix mail server correctly configured (I hope) and running on openSUSE 11.3. I can send email to local users from any location, but this also means that I (or anyone else) can send remote emails to the root account. How do I reject remote emails to the root account, while allowing regular users to receive email?

Best Answer

The correct way to reject certain addresses is to put this directive in the main.cf file:

smtpd_recipient_restrictions = 
    check_recipient_access hash:/etc/postfix/recipient_access
    ...

Then on the /etc/postfix/recipient_access file:

root@domain REJECT

followed by the usual:

postmap /etc/postfix/recipient_access