I configured Postfix with a custom before-queue filter script (fuglu) which inspects every incoming email first, and then adds the following header:
X-Fuglu-Test: Test Email
In postfix, I configured a header check to redirect email matching header above as follows:
/^X-Fuglu-Test:\sTest\sEmail/ REDIRECT testuser@myemailcomp.com
A test email sent to postfixin@mta.myinternalhost.com
on the MTA was successfully redirected to testuser@myemailcomp.com
, a user on a different MTA.
However, Postfix CC'd postfixin@mta.myinternalhost.com
, the original recipient, as part of the redirect.
What I've observed is that Postfix sends the CC along with the REDIRECT to the nearest relay MTA. That MTA delivers to testuser@myemailcomp.com
as expected, but also routes the email back to postfixin@myinternalhost.com
to encounter the filter again, which in turn REDIRECTs to testuser@myemailcomp.com
, ad infinitum.
Any way to prevent Postfix from doing a CC during a header_check REDIRECT?
Here's what my /var/log/maillog
looks like:
Jul 28 20:50:39 mta postfix/smtpd[4501]: connect from unknown[10.102.252.61]
Jul 28 20:50:39 mta postfix/smtpd[4504]: connect from localhost[127.0.0.1]
Jul 28 20:50:39 mta postfix/smtpd[4501]: NOQUEUE: client=unknown[10.102.252.61]
Jul 28 20:50:39 mta postfix/smtpd[4504]: A520EA0437: client=unknown[10.102.252.61]
Jul 28 20:50:40 mta postfix/smtpd[4506]: connect from localhost[127.0.0.1]
Jul 28 20:50:40 mta postfix/smtpd[4501]: NOQUEUE: client=unknown[10.102.252.61]
Jul 28 20:50:40 mta postfix/smtpd[4506]: 65C63A0446: client=unknown[10.102.252.61]
Jul 28 20:50:40 mta postfix/cleanup[4507]: 65C63A0446: **redirect**: header X-Fuglu-Test: Test Email from unknown[10.102.252.61]; from=<testuser@internal.com> to=<postfixin@mta.myinternalhost.com> proto=ESMTP helo=<sc-l-johnny.internal.com>: testuser@myemailcomp.com
Jul 28 20:50:40 mta postfix/cleanup[4507]: 65C63A0446: message-id=<>
Jul 28 20:50:40 mta postfix/qmgr[4281]: 65C63A0446: from=<testuser@internal.com>, size=1166, nrcpt=1 (queue active)
Jul 28 20:50:40 mta postfix/smtpd[4506]: disconnect from localhost[127.0.0.1]
Jul 28 20:50:40 mta postfix/smtpd[4501]: disconnect from unknown[10.102.252.61]
Jul 28 20:50:40 mta postfix/smtp[4508]: 65C63A0446: to=<testuser@myemailcomp.com>, orig_to=<postfixin@mta.myinternalhost.com>, relay=smtp-relay.internal.com[10.120.3.100]:25, delay=0.23, delays=0.19/0.01/0.01/0.03, dsn=2.0.0, status=sent (250 2.0.0 u6T3oe96012173 Message accepted for delivery)
Jul 28 20:50:40 mta postfix/qmgr[4281]: 65C63A0446: removed
Jul 28 20:50:44 mta postfix/smtpd[4501]: connect from microsoftrelay.internal.com[10.120.10.142]