Header RSS Feed
If you only want to see the articles of a certain category, please click on the desired category below:
ALL Android Backup BSD Database Hacks Hardware Internet Linux Mail MySQL Monitoring Network Personal PHP Proxy Shell Solaris Unix Virtualization VMware Windows Wyse

Postfix rewrite mail address ONLY for outgoing/sending e-mail
Wednesday - Jun 1st 2011 - by - (0 comments)

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 (bigcompany.com) bought small company (smallcompany.com) and from now on all outgoing e-mails must be sent with bigcompany.com addresses. But of course the mail server still needs to receive e-mails for smallcompany.com.

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 smallcompany.com will be replaced by bigcompany.com (and will therefore be relayed to the MX of bigcompany.com).

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 (smallcompany.com) but all sending domains need to be changed from ugly.domain to pretty.domain (bigcompany.com).


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


@smallcompany.com       @bigcompany.com


Add a comment

Show form to leave a comment

Comments (newest first):

No comments yet.

Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

6905 Days
until Death of Computers