Skip to main content

How to Remove Sensitive Data and Internal Network Information from 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. It is also very important to keep header details for your analysis. If any user started to spamming or compromised , then we must need header for analysis.
So we will remove only our client private network details.

We are assuming that postfix is already up and running and will make below changes.
Step:1 Edit ‘/etc/postfix/’ file
header_checks = regexp:/etc/postfix/header_checks
Step:2 Append the below line in ‘/etc/postfix/header_checks’ [at the bottom]
/^Received:/    IGNORE
Step:3 Run postmap to apply the new configuration in /etc/postfix/header_checks
[root@server1 ~]# postmap /etc/postfix/header_checks
Step:4 Restart or Reload the postfix server
[root@server1 ~]# systemctl restart postfix
[root@server1 ~]# postfix reload
Actually this setting will remove all incoming & outgoing header , and you will not find any header for incoming source to block spammer. So it's dangerous when you received lots of unsolicited or spamming email. This feature actually used for Subject line filtering. 
# vi /etc/postfix/header_checks
/Bitcoin/                               REJECT
/suspended incoming messages/           DISCARD
Now our objective is too remove our internal network information including header/sensitive data from email header only for outgoing email. Add the below line to Postfix main configuration file 
#remove outgoing header
smtp_header_checks = regexp:/etc/postfix/smtp_header_checks
Now Create the file as below and save . Don't forget to postmap . Now restart postfix
# vi /etc/postfix/smtp_header_checks

/^X-Mailer:/            IGNORE
/^Received:/            IGNORE
/^X-Original-IP:/       IGNORE
/^User-Agent:/          IGNORE
/^X-Mailer-Type:/       IGNORE
Now send an test mail to Google and collect email header & use MXToolBox  and analyze your header