Question
How to rewrite headers of outgoing mail messages?
For example, change
to
From: [email protected]
?
From: "Mailer-Daemon at server.example.com" <[email protected]>
Answer
This feature is not yet implemented in Plesk UI, but a feature request can be created on the Plesk UserVoice
As a workaround, use PostfixÂ
:
header_checks
-
Connect to the server via SSH ;
-
Add a
entry to the
header_checks
configuration file: the file specified will contain regular expressions for the rewriting:
/etc/postfix/main.cf
# postconf -e “header_checks = pcre:/etc/postfix/header_checks”
-
If the file
does not exist, create it:
/etc/postfix/header_checks
# [ ! -f /etc/postfix/header_checks ] && >/etc/postfix/header_checks
-
Modify the
file. For example, to rewrite all headers with
/etc/postfix/header_checks
to
From: [email protected]
, add the following line to the end of the file:
From: "Mailer-Daemon at server.example.com" <[email protected]>
/^From:[email protected]/ REPLACE From: "Mailer-Daemon at server.example.com" <[email protected]>
To hide server IP address from headers:
 /^Received:s+.*/ IGNORE
Note: For more information on regular expressions, refer to the PCRE documentation by php.net .
To change Message-ID:
/Message-Id:s+<(.*?)@server.example.com>/ REPLACE Message-Id: <[email protected]>
-
Reload Postfix to apply the enabled
:
header_checks
# service postfix reloadÂ
-
If a regular expression was applied to the mail message, a similar line will be appended to the
log file:
/var/log/maillog
server postfix/cleanup[21124]: E5CD0225EF9: replace: header From: [email protected] (Mail Delivery System) from local; from=<> to= [email protected] : From: "Mailer-Daemon at server.example.com" [email protected]
Note: For more information on header_checks feature in Postfix, refer to the Postfix documentation .