New Postfix Config

Here is my latest addition to my main.cf

smtpd_sender_restrictions = hash:/etc/postfix/deny

disable_vrfy_command = yes
smtpd_delay_reject = yes
smtpd_helo_required = yes
smtpd_helo_restrictions =
     permit_mynetworks,
     reject_non_fqdn_hostname,
     reject_invalid_hostname,
     permit

smtpd_recipient_restrictions =
        permit_mynetworks,
        reject_unknown_sender_domain,
        reject_invalid_hostname,
        reject_non_fqdn_hostname,
        reject_unauth_destination,
        reject_rbl_client b.barracudacentral.org,
        reject_rbl_client zen.spamhaus.org,
        reject_rbl_client spam.spamrats.com,
        reject_rbl_client bl.spamcop.net,
        permit

How to block domains (postfix) linux

Here a quick run down on how to block specific domains in postfix.

First edit the /etc/postfix/main.cf file

Add the following line:

smtpd_sender_restrictions = hash:/etc/postfix/deny

next create the deny file

/etc/postfix/deny (this is where you will put your list of domains)

Use this format:

yahoo.com    REJECT

Now use port map to that Postfix can read the file at startup.

postmap hash:/etc/postfix/deny

Now restart postfix

service postfix restart

Send a email from the domain… Yahoo for example to test, look at the log file.

tail /var/log/maillog

Note that after you add to the deny file you will need to use the portmap command again and restart postfix.