I have setup a postfix server that will receive several emails and deliver them to OpenERP. It's currently working, but I would like to improve the overall schema so that postfix delivers (i.e Delivered-To) to the OpenERP email alias.
More details about the instalation
The big schema is the following:
postfix-pgsql. In my
main.cffile I have something like:
alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = localhost virtual_alias_domains = mydomain.com virtual_alias_maps = pgsql:/etc/postfix/pgsql-aliases.cf
The query in
query = SELECT 'oerp@localhost' FROM mail_alias a, ir_config_parameter d WHERE (d.key = 'mail.catchall.domain') AND (d.value = '%d') AND (a.alias_name = '%u');
Then I have the "oerp" alias in
oerp: "| openerp_mailgate ...args... "
This setup works fairly well. Mails are being delivered, etc. But then, I have an out-of-my-control MTA (my postfix can relay to that for outsiders) that relays emails coming to "mydomain.com" to my postfix.
In that MTA there are several rules. For instance, I you email to "email@example.com", the MTA will re-deliver the email to "firstname.lastname@example.org" and "email@example.com". That redelivery won't touch original headers.
The "firstname.lastname@example.org" will handed to my postfix and, ultimately, it will end up being piped to the mailgate script. But the "Delivered-To" header will be changed to "oerp@localhost".
OpenERP looks for the "Delivered-To" header (among others) of the message to know what to do with it. But in this case the "Delivered-To" will always be the same and thus we can't use it for anything important.
I would like to change the schema so that postfix will deliver the email to my mailgate script without resorting to "oerp@localhost" alias and the "Delivered-To" remains unchanged (in the example it is expected to be "email@example.com").
Any ideas? I've been playing with the
master.cf but failed to accomplish