canada flag  linkedinfacebook   Call Us Today: (613) 494-5010

Postfix: drop a particular email

postfix-emailSometimes we have emails going to a particular address, which cannot be stopped. There are many reasons, but most common is an invalid address, which pollutes the mail queue with invalid entries. The simplest way to solve this is by adding a DISCARD directive for postfix. 

If you don't have it already, add this line in main.cf

header_checks = regexp:/etc/postfix/header_checks

Create the file (or add to it, if you already have one):

/blockemail@example\.com/    DISCARD

Finally, restart postfix:

/etc/init.d/postfix restart

The file header_checks is very useful for other things. You can, for example, add a subject line to the logs using header_checks file:

/^Subject:/ INFO

The above command directs postfix to save the Subject into the logs. This makes things easier when searching for an email in the logs. The code can be separated by line in header_checks. Keep in mind that the more you add to it, the slower postfix becomes.

Our support technicians have to deal with email related issues on a regular basis and have expertise in various systems, from Linux-based Postfix to Windows-based Exchange. If you are having email related issues and in need of IT consulting, feel free to contact us and our team of specialist will be more than happy to assist you. ALT is a full service IT cosulting firm, specializing in Linux, Windows and Mac systems support.

Original article posted on ALT Technical Miami.

Last updated Mar 22, 2019