Remove IPs from Outgoing Mail (Postfix SMTP)
I use Postfix as SMTP server. By default, it includes every user’s IP and hostname in outgoing mails, even internal ones. As there is no need for the outside world to see what IPs I use internally (or what external IPs my users connect from), I decided to remove IP headers from outgoing email. This post explains how.
Postfix (or any other SMTP server) receives mail from other mail servers (“incoming”), and mails by users (“outgoing”). As we don’t want to strip any headers from incoming mail, we first have to force all users to authenticate (which is a good thing anyway), and make Postfix add another header to authenticated (“outgoing”) mails. Then, we can match this header and strip both the Received line containing internal hostnames and IPs, and the authenticated header.
# add header for authenticated mail to strip IP
smtpd_sasl_authenticated_header = yes
header_checks = regexp:/etc/postfix/header_checks
/^Received: .*\(Authenticated sender:.*/ IGNORE
/^Received: by yourdomain\.com .*from userid [0-9]+\)/ IGNORE
(replace yourdomain.com by your server’s name)
- Source/Additional information: Noel Jones: About removing Received headers with internal IP addresses (10.09.2008, postfix-users mailing list)