Postfix To: address rewrite based on envelope_recipient
Posted on 2014-03-24
I'm trying to setup e-mail aliasing for a helpdesk software (Absolute Service). The theory is that each sender OU translates into a different alias which is then sent to a common account so that the helpdesk software can retrieve the message and assign it to the correct team based on the aliase it was sent to. For each OU in my google apps domain I am rewriting the envelope_recipient to route the message to an alias which identifies the senders OU.
For example. A sender in OU1 will write a message to email@example.com, when google rewrites the envelope_recipient the message will be turned into OU1firstname.lastname@example.org. The issue is that the "To: Helpdesk <email@example.com>" doesn't change on the message and this is the part that the helpdesk software is looking at to determine the appropriate team to assign the automatically created ticket.
My thoughts were to go one step further and rewrite the envelope_recipient to be OU1firstname.lastname@example.org and then have postfix rewrite the "To:" field but this has proved more difficult than I anticipated since postfix will only search and replace in the same header line.
I need postfix or something else to rewrite "To: Helpdesk <email@example.com>" in a message to be something else such as "To: Helpdesk <OU1firstname.lastname@example.org>" based on the envelope_recipient which would be OU1email@example.com.