Postfix masquerading or changing outgoing SMTP email or mail address

Address rewriting allows changing outgoing email ID or domain name itself. This is good for hiding internal user names. For example:
SMTP user: user-01
EMAIL ID: [email protected]
Server name:

However when user-01 send an email from shell prompt or using php it looks like it was send from [email protected]

Postfix MTA offers smtp_generic_maps parameter. You can specify lookup tables that replace local mail addresses by valid Internet addresses when mail leaves the machine via SMTP.

Open your file

sudo nano/etc/postfix/

Append following parameter and save the file.

smtp_generic_maps = hash:/etc/postfix/generic

Open /etc/postfix/generic file:

sudo nano /etc/postfix/generic

Add config to change [email protected] to [email protected].  Save and close the file.

[email protected] [email protected]

Create or update generic postfix table.

sudo postmap /etc/postfix/generic

Restart Postfix

sudo service postfix restart

When mail is sent to a remote host via SMTP this replaces [email protected] by [email protected] mail address.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.