Wednesday, September 13, 2017

How to Replace and Rewrite Sender Address in Postfix

I am setting up Postfix on a Linux server because I want to send mail independently. I need to change sender address because the default sender is from user@server.local.

This config changes sender addresses from both local originated, and relayed SMTP mail traffic:
# nano /etc/postfix/main.cf:
sender_canonical_classes = envelope_sender, header_sender
sender_canonical_maps =  regexp:/etc/postfix/sender_canonical_maps
smtp_header_checks = regexp:/etc/postfix/header_check
Rewrite envelope address from email originating from the server
# nano /etc/postfix/sender_canonical_maps:
/.+/    newsender@example.com
Rewrite from address in SMTP relayed e-mail
# nano /etc/postfix/header_check:
/From:.*/ REPLACE From: newsender@example.com

0 comments:

Post a Comment