When we send an email through our Postfix mail server, by default, Postfix adds a Received: header with the IP address of the computer where the email is sent from. We may want to hide this information to the email recipient's and the intermediate SMTP servers so the sender can not be tracked.

Postfix provides header_checks(5) to inspect the email's content and manipulate it. The Postfix parameter that we want to set is smtp_header_checks so the header removal only occurs in outgoing email, preserving all the Received: headers on the mail we receive at our SMTP.

The Postfix configuration for this behavior is the following:

/etc/postfix/main.cf:

...
smtp_header_checks = pcre:/etc/postfix/smtp_header_checks
...

/etc/postfix/smtp_header_checks:

/^Received: .*/     IGNORE
/^X-Originating-IP:/    IGNORE

The second line (X-Originating-IP) is there to make sure that this header doesn't go out of our SMTP if the MUA sets it.

After editing both files, just do a postmap pcre:/etc/postfix/smtp_header_checks and reload Postfix.

You'll probably need to install postfix-pcre package (at least in Debian) to provide PCRE support to Postfix.

Tagged as postfix, header_checks, track, client, received