[Mimedefang] stream_by_recipient and Postfix

Rolf E. Sonneveld R.E.Sonneveld at sonnection.nl
Tue Nov 22 08:49:37 EST 2011


Hi,

as a followup to my own question:

On 11/3/11 1:31 PM, Rolf E. Sonneveld wrote:
> Hi,
>
> running the latest version of MIMEdefang. I would like to be able to 
> do a per-recipient analysis of inbound mail, using Postfix. I know 
> that the MD stream_by_recipient feature requires a recent version of 
> Sendmail and probably will not work with Postfix, see for example:
>
> http://lists.roaringpenguin.com/pipermail/mimedefang/2009-May/034746.html
>
> As the information I found about the combination of MD, 
> stream_by_recipient and postfix is from 2009 and 2010, I wonder if 
> there have been any developments on this topic?
>
> Is anyone on this list running MD from within Postfix, using the 
> stream_by_recipient feature?
>
> Also, I'm not sure I understand the problem correctly: is the mail 
> split up into one-message-per-recipient to be able to run it again 
> through MIMEdefang? If so, the Postfix non_smtpd_milters option can be 
> used to have the reinjected messages be run through MD again?

It seems to work out fairly well, or maybe I should say: it runs 
perfectly well. I did some testing with Postfix 2.8.6 and MD 2.72. I 
used filter_begin:

sub filter_begin {
     my($entity) = @_;

     if (stream_by_recipient()) {

     return;

     }
}

and in postfix main.cf:

smtpd_milters = inet:localhost:25000
non_smtpd_milters = inet:localhost:25000

When I send a two-recipient message from Gmail I see in maillog:

Nov 22 14:22:07 lynx postfix/smtpd[1419]: connect from 
mail-fx0-f41.google.com[209.85.161.41]
Nov 22 14:22:07 lynx postfix/smtpd[1419]: 2172B1014AB: 
client=mail-fx0-f41.google.com[209.85.161.41]
Nov 22 14:22:07 lynx postfix/cleanup[1423]: 2172B1014AB: 
message-id=<CAJV=FeynXaz-t9CUYFZwEX4BeD8ara3+CQzmjq6Sj65vdNnkkw at mail.gmail.com>
Nov 22 14:22:07 lynx postfix/pickup[1416]: 4D6FF10151E: uid=602 
from=<mypersonaladdress at gmail.com>
Nov 22 14:22:07 lynx postfix/cleanup[1426]: 4D6FF10151E: 
message-id=<CAJV=FeynXaz-t9CUYFZwEX4BeD8ara3+CQzmjq6Sj65vdNnkkw at mail.gmail.com>
Nov 22 14:22:07 lynx mimedefang.pl[830]: 4D6FF10151E: 
MDLOG,4D6FF10151E,mail_in,,,mypersonaladdress at gmail.com,rolf2 at lynx.sonnection.nl,Test 
bericht 11
Nov 22 14:22:07 lynx postfix/qmgr[1415]: 4D6FF10151E: 
from=<mypersonaladdress at gmail.com>, size=1439, nrcpt=1 (queue active)
Nov 22 14:22:07 lynx postfix/local[1430]: warning: dict_nis_init: NIS 
domain name not set - NIS lookups disabled
Nov 22 14:22:07 lynx postfix/pickup[1416]: 679B310151D: uid=602 
from=<mypersonaladdress at gmail.com>
Nov 22 14:22:07 lynx postfix/cleanup[1426]: 679B310151D: 
message-id=<CAJV=FeynXaz-t9CUYFZwEX4BeD8ara3+CQzmjq6Sj65vdNnkkw at mail.gmail.com>
Nov 22 14:22:07 lynx mimedefang.pl[830]: 679B310151D: 
MDLOG,679B310151D,mail_in,,,mypersonaladdress at gmail.com.xyz,rolf at lynx.sonnection.nl,Test 
bericht 11
Nov 22 14:22:07 lynx mimedefang.pl[831]: 2172B1014AB: filter_begin set 
TerminateAndDiscard flag.
Nov 22 14:22:07 lynx mimedefang[3130]: 2172B1014AB: Discarding because 
filter instructed us to
Nov 22 14:22:07 lynx postfix/cleanup[1423]: 2172B1014AB: milter-discard: 
END-OF-MESSAGE from mail-fx0-f41.google.com[209.85.161.41]: milter 
triggers DISCARD action; from=<mypersonaladdress at gmail.com> 
to=<rolf at lynx.sonnection.nl> proto=ESMTP helo=<mail-fx0-f41.google.com>
Nov 22 14:22:07 lynx postfix/local[1430]: 4D6FF10151E: 
to=<rolf2 at lynx.sonnection.nl>, relay=local, delay=0.19, 
delays=0.11/0.06/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Nov 22 14:22:07 lynx postfix/qmgr[1415]: 4D6FF10151E: removed
Nov 22 14:22:07 lynx postfix/qmgr[1415]: 679B310151D: 
from=<mypersonaladdress at gmail.com>, size=1439, nrcpt=1 (queue active)
Nov 22 14:22:07 lynx postfix/local[1430]: 679B310151D: 
to=<rolf at lynx.sonnection.nl>, relay=local, delay=0.14, 
delays=0.12/0/0/0.02, dsn=2.0.0, status=sent (delivered to mailbox)
Nov 22 14:22:07 lynx postfix/qmgr[1415]: 679B310151D: removed
Nov 22 14:22:37 lynx postfix/smtpd[1419]: disconnect from 
mail-fx0-f41.google.com[209.85.161.41]

and a log file that's written to from within MD shows:

Connection from: 209.85.161.41
Name of connecting system: mail-fx0-f41.google.com
HELO/EHLO used by remote system: mail-fx0-f41.google.com
Connection from: 127.0.0.1
Name of connecting system: localhost
HELO/EHLO used by remote system: localhost
Entering filter_begin
Entering filter main routine (filter)
Entering filter_end routine
Connection from: 127.0.0.1
Name of connecting system: localhost
HELO/EHLO used by remote system: localhost
Entering filter_begin
Entering filter main routine (filter)
Entering filter_end routine

When I send a single-recipient message I get:

Nov 22 14:23:31 lynx postfix/smtpd[1419]: connect from 
mail-bw0-f41.google.com[209.85.214.41]
Nov 22 14:23:31 lynx postfix/smtpd[1419]: 3F5DA1014AB: 
client=mail-bw0-f41.google.com[209.85.214.41]
Nov 22 14:23:31 lynx postfix/cleanup[1423]: 3F5DA1014AB: 
message-id=<CAJV=Fey_J+4ZJD45uBRFcrEgACjkX0pftTo_Bj1O5ZZic5MBiQ at mail.gmail.com>
Nov 22 14:23:31 lynx mimedefang.pl[831]: 3F5DA1014AB: 
MDLOG,3F5DA1014AB,mail_in,,,<mypersonaladdress at gmail.com>,<rolf at lynx.sonnection.nl>,test 
bericht 12
Nov 22 14:23:31 lynx postfix/qmgr[1415]: 3F5DA1014AB: 
from=<mypersonaladdress at gmail.com>, size=1314, nrcpt=1 (queue active)
Nov 22 14:23:31 lynx postfix/local[1430]: 3F5DA1014AB: 
to=<rolf at lynx.sonnection.nl>, relay=local, delay=0.21, delays=0.2/0/0/0, 
dsn=2.0.0, status=sent (delivered to mailbox)
Nov 22 14:23:31 lynx postfix/qmgr[1415]: 3F5DA1014AB: removed
Nov 22 14:24:01 lynx postfix/smtpd[1419]: disconnect from 
mail-bw0-f41.google.com[209.85.214.41]

and:

Connection from: 209.85.214.41
Name of connecting system: mail-bw0-f41.google.com
HELO/EHLO used by remote system: mail-bw0-f41.google.com
Entering filter_begin
Entering filter main routine (filter)
Entering filter_end routine

Is this sufficient 'evidence' that MD + stream_by_recipient()+ Postfix 
(non_smptd_milters) provides a solution to the problem of treating a 
multi-recipient message differently based upon different 'per-user' 
preferences/settings? Any things I forgot? Any caveats?

I realize that with this setup, it is not possible to provide the 
sending MTA an 'after-DATA' per-user status code, but that problem is 
not an MD problem, it's rather a flaw in the design of SMTP.

/rolf



More information about the MIMEDefang mailing list