Click Technology

Linux, Windows, Mac it's all good

Ban a sender from sending you mail on Postfix

September7

This is quite handy and easy to set up.

First, open up main.cf, the principal configuration file in Postfix. I use vim, but of course you can use whatever editor you like, e.g. vi, nano etc.

sudo vim /etc/postfix/main.cf

In your main.cf, add the following lines in the configuration

smtpd_sender_restrictions =
        check_sender_access hash:/etc/postfix/sender_access

Now, create a file to store the list of banned names.

sudo touch /etc/postfix/sender_access

and now edit it to add the banned names…

sudo vim /etc/postfix/sender_access

Add the banned addresses in the following format..

news@z.mindsportzero.com REJECT
subscriptions@cashiq.net REJECT
business-quote@receiveyourquote.co.uk REJECT
penny.fox@flashmarketing.info REJECT
enquiries@flashmarketing.info REJECT

Save the file. Now, create the hashed db file for this file..

sudo postmap /etc/postfix/sender_access

Now you should have a file in the /etc/postfix directory called /etc/postfix/sender_access.db

Now all you need to do is restart postfix.

sudo service postfix restart

Tanaaaa!

posted under Linux Tips

Email will not be published

Website example

Your Comment:

This is my website for short blog posts and interesting materials that are noteworthy or have some handy-tip value.