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. |
the rewrite tables will target specific email addresses. you should be familiar with this.
|
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 A quick test seems to suggest that this does the trick, though I'll check more thoroughly in the morning. Hurrah -- thanks again! Stuart. |
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. |
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?
|
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. |
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. |