OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
[Newbie] redirect incoming mail to external mail => rewrite headers too

From: Olivier Hoareau (hoareau.oliviergmail.com)
Date: Fri Dec 07 2007 - 04:48:21 CST


Hi !

I am a newbie in Postfix, I just intalled it on Fedora Core 6 with
dovecot and MySQL support (virtual domains).

I want to redirect all the incoming mail for a specific user to a
specific external email :

Let's say I have a domain1.tld whose dns are set to my postfix host, I
have a mysql table "emails" where I have 2 fields => "for" and
"redirectto", and when a mail arrives I want to check in the mysql
"emails" table if the recipient exists in field "for" and if yes get the
"redirectto" email and redirect via postfix the incoming email to the
"redirectto" email.

It was working with canonical_maps (I think) but the problem is the
headers are not rewritten and if the "redirectto" email is for example
an-external-accountgmail.com, GMail servers drop the incoming message
because it was sent to <someuser>domain1.tld. So I want postfix to
rewrite all header containing <someuser>domain1.tld to
an-external-accountgmail.com, in order for gmail to not drop the message

Is it possible ?

thx in advance,

Olivier H.