I see several problems with the content filter.

First the content filter appears to be using the same temporary
file when different messages arrive at almost the same time.

Before your content filter, these messages have different message
IDs:

    message-id=<0.0.a.f4.1cef44d1247f0b...@mta147.esp4.eu>
    message-id=<3CCEA7A26F3E4A69BAD8578B55ED7319@m19c68eb1c6704>

After your content filter, the messages have the same message ID:

    message-id=<0.0.a.f4.1cef44d1247f0b...@mta147.esp4.eu>
    message-id=<0.0.a.f4.1cef44d1247f0b...@mta147.esp4.eu>

This means that the messages were using the same file.

> $file=uniqid();
> $f=fopen($file,'w');

Try prepending the process ID to the uniqid() result.

Second, your content filter will mis-deliver email with more than
one recipient. 

As documented in the pipe(8) manpage, ${recipient} will expand into
multiple command-line arguments.

> filter    unix  -       n       n       -       10      pipe
>   flags=Rq user=marcin null_sender=
>   argv=/usr/bin/filter_poczta.php -s ${sender} -r ${recipient} -u 
> ${sasl_username}

To avoid this error specify:

/etc/postfix/main.cf:
    filter_destination_recipient_limit = 1

(and execute "postfix reload").

I suspect that there is a similar issue with your pipe-to-dovecot
adapter. Again, setting "dovecot_destination_recipient_limit = 1"
will avoid this error.

        Wietse

Message 1 before filter:

> Dec  8 20:36:26 serwery postfix/smtpd[2112]: connect from 
> mta147.esp4.eu[178.33.185.147]
> Dec  8 20:36:27 serwery postfix/smtpd[2112]: 0DFFADE3C8B: 
> client=mta147.esp4.eu[178.33.185.147]
> Dec  8 20:36:27 serwery postfix/cleanup[27880]: 0DFFADE3C8B: 
> message-id=<0.0.a.f4.1cef44d1247f0b...@mta147.esp4.eu>
> Dec  8 20:36:27 serwery postfix/qmgr[5555]: 0DFFADE3C8B: 
> from=<28565-59746...@codziennie1prezent.pl>, size=20398, nrcpt=1 (queue 
> active)
> Dec  8 20:36:27 serwery postfix/smtpd[2112]: disconnect from 
> mta147.esp4.eu[178.33.185.147]
> Dec  8 20:36:27 serwery postfix/pipe[24740]: 0DFFADE3C8B: 
> to=<us...@mydom2.pl>, relay=filter, delay=0.3, delays=0.16/0.02/0/0.13, 
> dsn=2.0.0, status=sent (d
elivered via filter service)
> Dec  8 20:36:27 serwery postfix/qmgr[5555]: 0DFFADE3C8B: removed

Message 1 after filter:

> Dec  8 20:36:27 serwery postfix/pickup[23435]: 4D495DE3C8B: uid=500 
> from=<28565-59746...@codziennie1prezent.pl>
> Dec  8 20:36:27 serwery postfix/cleanup[27880]: 4D495DE3C8B: 
> message-id=<0.0.a.f4.1cef44d1247f0b...@mta147.esp4.eu>
> Dec  8 20:36:27 serwery postfix/qmgr[5555]: 4D495DE3C8B: 
> from=<28565-59746...@codziennie1prezent.pl>, size=20507, nrcpt=1 (queue 
> active)
> Dec  8 20:36:27 serwery dovecot: lda(us...@mydom2.pl): sieve: 
> msgid=<0.0.a.f4.1cef44d1247f0b...@mta147.esp4.eu>: stored mail into mailbox 
> 'INBOX'
> Dec  8 20:36:27 serwery postfix/pipe[1473]: 4D495DE3C8B: 
> to=<us...@mydom2.pl>, relay=dovecot, delay=0.48, delays=0.2/0/0/0.28, 
> dsn=2.0.0, status=sent (deli
vered via dovecot service)
> Dec  8 20:36:27 serwery postfix/qmgr[5555]: 4D495DE3C8B: removed

Message 2 before filter:

> Dec  8 20:36:27 serwery postfix/smtpd[6007]: connect from ut.pl[178.250.45.37]
> Dec  8 20:36:27 serwery postfix/smtpd[6007]: 1B54EDE3C90: 
> client=ut.pl[178.250.45.37]
> Dec  8 20:36:27 serwery postfix/cleanup[28725]: 1B54EDE3C90: 
> message-id=<3CCEA7A26F3E4A69BAD8578B55ED7319@m19c68eb1c6704>
> Dec  8 20:36:27 serwery postfix/smtpd[6007]: disconnect from 
> ut.pl[178.250.45.37]
> Dec  8 20:36:27 serwery postfix/qmgr[5555]: 1B54EDE3C90: from=<bi...@ut.pl>, 
> size=975, nrcpt=1 (queue active)
> Dec  8 20:36:27 serwery postfix/pipe[7758]: 1B54EDE3C90: 
> to=<us...@mydom1.pl>, relay=filter, delay=0.18, delays=0.06/0.02/0/0.11, 
> dsn=2.0.0, status=sent (d
elivered via filter service)
> Dec  8 20:36:27 serwery postfix/qmgr[5555]: 1B54EDE3C90: removed

Message 2 after filter (note that the content has been replaced 
with message 1, but the sender and recipient have not been replaced):

> Dec  8 20:36:27 serwery postfix/pickup[23435]: 43E18DE3C9A: uid=500 
> from=<bi...@ut.pl>
> Dec  8 20:36:27 serwery postfix/cleanup[28725]: 43E18DE3C9A: 
> message-id=<0.0.a.f4.1cef44d1247f0b...@mta147.esp4.eu>
> Dec  8 20:36:27 serwery postfix/qmgr[5555]: 43E18DE3C9A: from=<bi...@ut.pl>, 
> size=20507, nrcpt=1 (queue active)
> Dec  8 20:36:27 serwery dovecot: lda(us...@mydom1.pl): sieve: 
> msgid=<0.0.a.f4.1cef44d1247f0b...@mta147.esp4.eu>: stored mail into mailbox 
> 'INBOX'
> Dec  8 20:36:27 serwery postfix/pipe[18099]: 43E18DE3C9A: 
> to=<us...@mydom1.pl>, relay=dovecot, delay=0.28, delays=0.08/0/0/0.2, 
> dsn=2.0.0, status=sent (del
ivered via dovecot service)
> Dec  8 20:36:27 serwery postfix/qmgr[5555]: 43E18DE3C9A: removed

Reply via email to