postfix remove headers with MailScanner

por | 10 marzo, 2016

I use postfix with MailScanner and that’s why I cannot use:

/^Received:/ IGNORE

in my header_checks file, because i use:

/^Received:/ HOLD

(see )

But it’s no problem, because it’s possible to remove mail headers also with


You want to remove information about your LAN structure from mail headers sent
from your LAN and you use MailScanner for spam and virus check.

Let your LAN is and let your SMTP gateway (postfix+MailScanner)


1. open /etc/MailScanner/MailScanner.conf

2. find «Remove These Headers» in MailScanner.conf. In default MailScanner.conf
it should be something like this:

Remove These Headers = X-Mozilla-Status: X-Mozilla-Status2:

3. change this line to this:

Remove These Headers = %rules-dir%/remove.headers.rules

4. save and close MailScanner.conf

5. create/open file /etc/MailScanner/rules/remove.headers.rules (if your
%rules-dir% is /etc/MailScanner/rules) and put these 2 lines into remove.
headers.rules file:


Nota el que use:

From: default Received: X-Mailer: X-MimeOLE:

From: 192.168.1. Received: X-Mailer: X-MimeOLE:
FromOrTo: default X-Mozilla-Status: X-Mozilla-Status2:

6. save and close remove.headers.rules and restart/reload MailScanner

First line in remove.headers.rules means: if mail connection is from my LAN
( then remove mail headers ‘Received:’, ‘X-Mailer:’ and
‘X-MimeOLE:’ from this connection. There are no other ‘Received:’ headers in
this connection than ‘Received:’ with IP addresses of your LAN computers. If
email is comming from internet, then this line is omitted and you can see all
‘Received:’ headers in incomming email (and that’s what you want 🙂 ).

Second line is default condition (if first line is not matched) and for this
line I use default value from MailScanner.conf. You can put what you want in
this line or remove this line if no default condition is needed.

This solution works for me.


P.S: I’m sorry for my english, it’s not my native language.