Postfix rewrite mail address ONLY for outgoing/sending e-mail

Written by - 0 comments

Published on - Listed in Linux Mail

In these days I have a case where I have to change the domain name of e-mail addresses which are sent out to the Internet. So all e-mails sent out to the Internet need to have the sending addresses changed.

To be more specific: Big company ( bought small company ( and from now on all outgoing e-mails must be sent with addresses. But of course the mail server still needs to receive e-mails for

After some research I found the parameter smtp_generic_maps, which looks pretty good:

" When mail is sent to a remote host via SMTP, this replaces  his@localdomain.local by his ISP mail address, replaces her@localdomain.local by her ISP mail address, ...."

But the problem is, that my Postfix solution is a mail gateway (anti-spam, anti-virus) in front of an Exchange server. Therefore the mailboxes are not on the Postfix server and e-mails are forwarded... yes... to a remote host. So even for incoming e-mails the smtp_generic_maps parameter will be applied and will be replaced by (and will therefore be relayed to the MX of

So I had to look for another solution. This time I found what I was looking for: The sender_canonical_maps parameter! In the documentation the following text describes this parameter:

Example: you want to rewrite the SENDER address "user@ugly.domain" to "user@pretty.domain", while still being able to send mail to the RECIPIENT address "user@ugly.domain".

Yes - this is exactly what I need. I still need to be able to receive e-mails for ugly.domain ( but all sending domains need to be changed from ugly.domain to pretty.domain (


# Change outgoing email addresses to be
# 01.06.2011 Claudio
sender_canonical_maps = hash:/etc/postfix/sender_canonical


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.