Postfix has the ability to reject mail based on regular expression matching in the header of the incoming mail message. To enable this, add these lines to main.cf:
header_checks = regexp:/etc/postfix/header_checks header_checks = pcre:/etc/postfix/header_checks |
We stuck these after the alias line. Add the header content matches and actions to header_checks (usually in /etc/postfix) and restart postfix. Here is an example match and action:
/badwordnotallowed/ REJECT No Spam Allowed |
The logs will show the email being rejected:
Jul 29 09:18:38 main postfix/cleanup[3479]: E855A5555BA: reject: header Subject: badwordnotallowed from host.example.com[200.0.1.8]; from=<> to=<host2@example.co m> proto=ESMTP helo=<host.example.com>: No Spam Allowed |