How to block domains (postfix) linux

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

First edit the /etc/postfix/ 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:    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.