How to filter mail with postfix header_checks

Firstly, if you are not using SSL for all your sites, you should step it up! NameCheap's SSL certificates start at only $9. There's no excuse!
Firstly, if you have not tried Digital Ocean's SSD Virtual Servers for only $5/mo, I highly recommend them!

There’s a lot of static on Google about this, so I’ll just re-document it here. You can filter email in postfix with the header_checks parameter in your You specify that you want to use regular expressions and you specify the file that holds them:

header_checks = regexp:/etc/postfix/header_checks

The syntax in the header_checks file is:
/regex_pattern/ ACTION

See a full list of possible actions here

I’m doing three things in the example.
– If the sender’s email address starts with “spammer”, then REJECT it.
– If an email is sent to bob on my server, forward it bob’s real email address
– If the subject contains “Viagra” then discard it.


/^From: "spammer/ REJECT


/^Subject:.*viagra/ DISCARD

Here are a bunch of rules for those anti-virus spams.

About this entry

Good Reads