Home   Profile   Fun
#125 Linux  03.06.2007

How to rewrite the sender address in Postfix


Let's assume we have Postfix running on a webserver and we want to rewrite the sender address of mails coming from the apache user of this server. The only thing to do is to add a line to the main configuration file and create or modify a lookup table.

Tell Postfix were to find the lookup table with the required information by inserting the following line into /etc/postfix/main.cf:
sender_canonical_maps = hash:/etc/postfix/sender_canonical

Open or create the file /etc/postfix/sender_canonical and insert the line with the new email address.
apache someuser@differentdomain.de

Create a lookup table from this file
postmap hash:/etc/postfix/sender_canonical
which creates or updates /etc/postfix/sender_canonical.db

To activate these changes restart Postfix
/etc/init.d/postfix restart