LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Postfix -- selective forwards for external domains (https://www.linuxquestions.org/questions/linux-server-73/postfix-selective-forwards-for-external-domains-916155/)

stuartsjb 11-29-2011 04:53 AM

Postfix -- selective forwards for external domains
 
Hello,

I would like Postfix to rewrite certain recipient addresses, for an external domain.

That is, I have a web application that sends email to @company.com -- which is a domain that is not hosted on my server.

I want to intercept and rewrite certain addresses in the 'to' field of outgoing email:
stuart@company.com --> stuart@abc.com
sheila@company.com --> ssmith@abc.com

... but I want every other email to be delivered as normal, through the mail gateway:
justin@company.com --> justin@company.com
...
@company.com --> @company.com

I don't think I can do this using virtual domains -- I could do the first part, but I can't see how I could then say, "for everything else, deliver as normal", as I don't need a normal catch-all.

Any ideas?

Many thanks,
Stuart.

Berhanie 11-29-2011 12:14 PM

the rewrite tables will target specific email addresses. you should be familiar with this.

stuartsjb 11-29-2011 02:18 PM

Thank you very much, Berhanie -- this allowed me to piece together the jigsaw, without thinking that I was looking in the wrong place! For reference for anyone in a similar boat, I've done the following:

Created the file /etc/postfix/canonical, and put the following lines in it:
And run sudo postmap /etc/postfix/canonical to create the hashed table.

Then added the following line to /etc/postfix/main.cf:
Code:

canonical_maps = hash:/etc/postfix/canonical
And run sudo postfix reload.

A quick test seems to suggest that this does the trick, though I'll check more thoroughly in the morning. Hurrah -- thanks again!

Stuart.

Berhanie 11-29-2011 05:26 PM

ok, if that works for you. canonical has specific semantics, which is to make locally significant addresses, such as bob@localhost.localdomain, into something meaningful to the rest of the world.

correction: i described the generic map, not canonical. generic is used to transform localhost.localdomain into a valid domain. canonical is used to transform valid email addresses, e.g. bsmith@example.com, into a domain-specific standard form,
e.g. bob.smith@example.com.

stuartsjb 11-30-2011 09:20 AM

That's handy to know -- thanks for that! The method I described does seem to work for me -- do you happen to know which table I should have used though, to align with standard use?

Berhanie 11-30-2011 09:52 AM

i would first try virtual alias. i'd have to look at the man pages again to make sure.

as you see, there are several ways of doing it, but if i were working on an unfamiliar postfix system, looking for the place where you put these aliases, that's the map i'd check first.

stuartsjb 01-08-2012 10:56 AM

Mmmm, having now read around this some more, I think you're right that the mapping I was using should ideally have sat in the virtual alias file, which is handy to know for the future. Many thanks again for your help, Berhanie!


All times are GMT -5. The time now is 06:15 AM.