Postfix blacklist or reject an email address
Q. I’ve Postfix based CentOS Linux server. I need to blacklist email ID: user@abadboy.com . How do I blacklist email address with postfix? I also have spamassassin software installed.
A. By default, the Postfix SMTP server accepts any sender address. However you can block / blacklist sender email address easily with Postfix. It has SMTP server access table.
Open /etc/postfix/sender_access file
# cd /etc/postfix
# vi sender_access
Append sender email id as follows:
user@abadboy.com REJECT
Save and close the file. Use postmap command to create a database:
# postmap hash:sender_access
Now open main.cf and add code as follows:
smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_access
Save and close the file. Restart / reload postfix MTA:
# /etc/init.d/postfix restart
You can also use spamassassin to blacklist email address. Just add to your own spamassassin configuration or to /etc/mail/spamassassin/local.cf file:
# vi /etc/mail/spamassassin/local.cf
Append blacklist as follows:
blacklist_from user@abadboy.com
Save and close the file. Restart spamassassin:
# /etc/init.d/spamassassin restart
spamassassin will marke mail as SPAM instead of rejecting the same.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Sendmail blocking spam email id, ips with access database
- Linux BIND DNS Configure Sender Policy Framework ( SPF ) an e-mail Anti Forgery System
- Postfix setup catch-all email accounts using /etc/postfix/virtual
- Qmail allow email from my own domain (particular domain) only
- CentOS / Red Hat / Fedora Linux Turn off Beep / Bell Terminal Sound
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: access_file, blacklist, centos_linux, email, linux_server, postfix, sender_address, smtp_server, spamassassin



November 5th, 2007 at 2:56 pm
Thanks! Very helpful.
Ony one slight error: The main.cf line should read:
November 6th, 2007 at 7:15 am
Thanks for the heads up!
January 21st, 2008 at 5:09 pm
Please correct to:
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access
Using the given line, the mail server will not accept communication…yet shows to be running.
Test with ‘telnet localhost 25′
Normally, you should get a response such as:
220 {yourmailserverFQDN} ESMTP Postfix
January 21st, 2008 at 5:13 pm
While not stated above, this should work for whitelisting senders as well. Ideal when you don’t want to whitelist someone’s misconfigured exchange server.
May 5th, 2008 at 12:13 pm
I am not able to start internet from RHEL 5
please help me out!!!
plz give step by step instructions