Postfix: Rewrite sender on outgoing mails


With Postfix you can rewrite the sender, respectively the from-headers for outgoing mails. Prerequesite is an existing Postfix installation.

Create the /etc/postfix/sender_canonical, with the following example content (you may use spaces or tabs to separate the columns):

root     info@example.net
www-data         www@example.net
test@example.net test2@example.net

Next create the sender_canonical.db file:

postmap hash:/etc/postfix/sender_canonical

Add sender_canonical variable to /etc/postfix/main.cf:

postconf -e "sender_canonical_maps=hash:/etc/postfix/sender_canonical"

Restart Postfix:

/etc/init.d/postfix restart

And that's it. For example outgoing mail from your webserver (www-data) will be sent out from www@example.net.