Remove Sensitive Postfix Headers

E-mail header contain some sensitive information. I’ll show you how to remove that information from the Postfix headers. note: some email clients will mark your email as spam if your header doesn’t contain an IP address.

Create a file in the postfix directory

sudo vim etc/postfix/oyvey

Paste the following in the file:

/^Received:.*with ESMTPSA/ IGNORE
/^X-Originating-IP:/ IGNORE
/^X-Mailer:/ IGNORE
/^Mime-Version:/ IGNORE (only add the ESMTPSA line when you use SMTP authentication trough port 465)

Open the Postfix config /etc/postfix/main.cf and add the following two lines:

mime_header_checks = regexp:/etc/postfix/oyvey
header_checks = regexp:/etc/postfix/oyvey

Rebuild the hash table:

postmap /etc/postfix/oyvey
postfix reload