postfix: generic & transport are driving me nuts

Installing, Configuring, Troubleshooting server daemons such as Web and Mail
Post Reply
majun
Posts: 145
Joined: 2010/03/11 11:33:59

postfix: generic & transport are driving me nuts

Post by majun » 2014/02/11 14:47:04

Methings me too stupid for postfix...

I've run into a problem with postfix I can't wrap my head around. Well, I sort of can and it makes sense to me but it can't be the way it's been designed...
  • One central MTA for incoming and outgoing emails (Domain for incoming mails: @company.com; internal domain: site.com).
  • Several remote servers located far far away from said central MTA handling different subdomains for their respective sites: city1.site.com, city2.site.com, location1.city2.site.com, location2.city2.site.com, city3.site.com, etc. Important notice: the local domain site.com is different from the official @company.com one and is only used internally.
  • The mapping between external email adress first.name@company.com and the internal username@city2.site.com is done via aliases on the central MTA.
  • The internal destination hosts for city1.site.com, city2.site.com, etc. are defined via individual entries in transport, each site has its own local MTA. Thus, transport contains entries like "city1.site.com      smtp:server.city1.site.com".
So far, so good. Everything works as expected. However, a new groupware solution we've decided to use (and, unfortunately, already bought and paid for) is as stupid as night as black and uncapable of handling multiple internal domains different from external addresses, hence users keep sending out emails with a worthless "username@city1.site.com" sender addresses. Needless to say these merely internal city1.site.com domains do not have official MX or A records outside our company network. Thus, our clients keep complaining that their mails to us keep bouncing. I've started looking into this and found out that this is precisely what generic is for. However, this is where I fail to see the logic. When adding a new generic entry "username@city1.site.com     firstname.lastname@company.com" or, more generally speaking "@city1.site.com     @company.com", masquerading works just as expected, meaning that mails initially sent out as username@city1.site.com get mapped to firstname.lastname@company.com correctly. However, postfix fails to deliver incoming messages to its final recipient because it first remaps the address from firstname.lastname@company.com to username@city1.site.com via aliases and then - instead of going straight to transport without touching it again - looks up the destination for city1.site.com via transport, and then remaps the address back to firstname.lastname@company.com via generic before sending the message on its way to its final destination.

In short:
What I expect: 1) receive message; 2) remap external to internal address via aliases; 3) look up destination via transport; 4) deliver message
What it does: 1) receive message; 2) remap external to internal address via aliases; 3) look up destination via transport; 4) remap internal to external address via generic; 5) deliver message

The remote MTA receives these messages and immediately relays them because of an incorrect destination - the remote MTA's $mydestination is city1.site.com and not company.com. Thus, the message gets relayed back to the central MTA that serves as relayhost for all other MTAs and the entire game begins anew. After a few seconds I get a "too many hops" bounce and that's that. I absolutely do see the logic behind this in that step 4 in the latter case is, as far as postfix is concerened, a new message and not the original message anymore. The original message has been accepted by postfix and copied as new message destined for delivery. Thus, the process of remapping and delivery beings anew. However, this can't be the way it's designed so I'm fairly sure it's a layer 8 problem and I'm the stupid one here. How do I handle this problem, any ideas?

Post Reply