Postfix blacklist or reject an email address

Q. I’ve Postfix based CentOS Linux server. I need to blacklist email ID: . 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: REJECT
Save and close the file. Use postmap command to create a database:
# postmap hash:sender_access
Now open 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/ file:
# vi /etc/mail/spamassassin/
Append blacklist as follows:
Save and close the file. Restart spamassassin:
# /etc/init.d/spamassassin restart

spamassassin will marke mail as SPAM instead of rejecting the same.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
28 comments… add one
  • Kiruba May 14, 2013 @ 5:04


    i wants to accept mail from blocked users and discard mail in Postfix server itself with out any bounce back.

    Pls give some tips ASAP…………

  • Ojay May 25, 2013 @ 23:32

    @dnaduz you may have fixed it, however it could be that you need to move the rule up the line….that worked for me!

  • Doesn't work Oct 25, 2013 @ 4:07

    It doesn’t work am still getting emails from an address I blocked :(

  • shahzaibcb Dec 29, 2013 @ 11:31

    I want to discard any email that is recieved on my domain account i.e using postfix. Can you guide me regarding it ?

  • Sam Jun 16, 2014 @ 17:21


    I have MySQL table listing allowed sender email addresses. I like to receive emails only from allowed people. Can I do this using MySQL instead of file? Also, I like to collect email address of sender who sent email, but wasn’t allowed so I can send him/her custom auto reply. Any way to do this?


  • chinnachamy May 25, 2015 @ 5:17

    How do i remove separate spam mail id

  • ken Jun 28, 2016 @ 7:18


    I am currently using FC21 as my email server. and I followed the instructions here but I still get annoying emails from with chinese characters that I don’t understand.

    Please help me.

    Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.