Saturday, May 19, 2012

Filter mail with postfix header_checks


First up under /etc/postfix ensure that you have a file called header_checks. If not create it.
Next we want to ensure Postfix is configured to use this file so you do this from a command line by entering the following:
postconf -e "header_checks = regexp:/etc/postfix/header_checks"
The syntax in the header_checks file is:
/regex_pattern/ ACTION
Example :
#/etc/postfix/header_checks

/^From: "spam/ REJECT

/^To: example@example.com/ REDIRECT @esxe.com

/^Subject:.*viagra/ DISCARD
More Detail Link 1 Link 2

1 comment:

  1. Thanks for the very clear article, but with the case redirect:
    /^To: example@example.com/ REDIRECT @esxe.com
    How can I redirect (or bcc) to more than 1 mailbox?

    ReplyDelete