Postfix check_headers

Playing with postfix check_headers directive

Application: Postfix
Version: 2.9
System: Debian
Description:
Use check_headers to replace some headers from emails send by postfix

Basics:

  • settings in main.conf:
    • header_checks = regexp:/etc/postfix/header_check
      Meaning: regexp is one of the methods
  • file header_check:
    • /(.*)(something)/ REPLACE $1
      Meaning: will find "something" and replace it with $1=(.*)[everything before], it means deletion of "something"

      /^(Received: from somehost)(.*)/ REPLACE X-$1$2
      Meaning: will match (everything in bracket) eg $1 and replace it with X-$1[X-Received: from somehost] and append the rest of the header

      /^Received: from 127.0.0.1/ IGNORE

      /^Received: from localhost/ IGNORE

      /(.*)(..\(This is the line from multiline header\))(.*)/ REPLACE $1$3
      Meaning: will add strings before, $2=[can be second line for example] replace with nothing and append the rest BEWARE of .. which is needed to have proper header format otherwise you can received BAD HEADER and ur mgs can be discarted

Suburban Glory Web Design
„Když už člověk jednou je, tak má koukat aby byl. A když kouká, aby byl a je, tak má být to, co je a nemá být to, co není, jak tomu v mnoha případech je.“ Jan Werich