Yahoo are still sending me spam, so I’ve decided to block all emails from yahoo.com, this is the method I’ve used:
1) Create a file using with your blacklisted addresses/domains with customised responses as follows:
# Specific users firstname.lastname@example.org 550 Sorry user, I've had enough of your spam # Whole domains example2.com 550 Messages not accepted from the example2.com domain # Whole domains with a non-customised response example3.com REJECT
2) Convert this text file into a Postfix-compatible database with postmap file (output will be file.db) (Note: on Debian systems will need to be root to run postmap)
2a) Put the file into the /etc/postfix folder
3) Open /etc/postfix/main.cf
4) Reference file.db with
check_sender_access hash: /path/to/file (leave off the .db extension)
option in your smtpd_recipient_restrictions directive.
My main.cf looks like this:
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination, check_sender_access hash:/etc/postfix/yahoo
The above is all one line.
And my test email was rejected:
Mar 7 18:44:09 mail postfix/smtpd: NOQUEUE: reject: RCPT from nm14.bullet.mail.bf1.yahoo.com[22.214.171.124]: 550 5.7.1 email@example.com: Sender address rejected: Sorry Yahoo! email user, too much spam from your domain, try using gmail.; firstname.lastname@example.org email@example.com proto=SMTP helo=
And will look something like this to the person sending the email:
Credit to MJN.