El 2017-11-03 11:05, [email protected] escribió:
Noel Jones:
On 11/2/2017 7:48 AM, [email protected] wrote:
> Hi,
>
> I'm running Postfix 2.9.6 and I'm trying to do a conditional sender
> rewrite based on recipient address. Machine sends e-mails as
> [email protected] by default, but if the recipient is
> [email protected] I want to rewrite sender to be
> [email protected].
>
> To do so, I've tried doing the following:
>
> 1) In master.cnf I added:
>    toext     unix  -       -       n       -       -       smtp -o
> canonical_maps=hash:/etc/postfix/generic_toext

Perhaps with smtp_generic_maps, but not with canonical
maps because that happens before the queue.

        Wietse

Thank you.

By now I'm trying to implement a content filter to change some headers of the received message. To do that, I added a service to the master.cf file:

  external   unix  -       n       n       -       -       pipe
    flags=Fq user=user:user argv=/opt/scripts/external.sh ${recipient}

The script is a very simple bash script that replaces the 'From' header:

    #!/bin/bash

    content=$(cat)
contfin=$(sed 's/From: [email protected]/From: [email protected]/' <<< "$content")

    TMPFILE=`mktemp`
    echo $contfin > $TMPFILE

cat $TMPFILE | /usr/sbin/sendmail -G -i -f [email protected] -- $1

    /bin/rm -f $TMPFILE

    exit $?

In transports map file (postmapped):

    [email protected]  external:

The script seems to do what it should, however, in the Postfix logs it seems to loop, like the message was put in the queue again and passed to the queue over and over (and the message never arrives):

Nov 3 11:13:52 machine postfix/pickup[19571]: 965731DA9: uid=0 from=<root> Nov 3 11:13:52 machine postfix/cleanup[19751]: 965731DA9: message-id=<[email protected]> Nov 3 11:13:52 machine postfix/qmgr[19572]: 965731DA9: from=<[email protected]>, size=307, nrcpt=1 (queue active) Nov 3 11:13:52 machine postfix/pickup[19571]: AB1CA613A: uid=110 from=<[email protected]> Nov 3 11:13:52 machine postfix/cleanup[19751]: AB1CA613A: message-id=<> Nov 3 11:13:52 machine postfix/pipe[19753]: 965731DA9: to=<[email protected]>, relay=external, delay=0.12, delays=0.08/0/0/0.04, dsn=2.0.0, status=sent (delivered via external service)
    Nov  3 11:13:52 machine postfix/qmgr[19572]: 965731DA9: removed
Nov 3 11:13:52 machine postfix/qmgr[19572]: AB1CA613A: from=<[email protected]>, size=117, nrcpt=1 (queue active) Nov 3 11:13:52 machine postfix/pickup[19571]: BDEB56499: uid=110 from=<[email protected]> Nov 3 11:13:52 machine postfix/cleanup[19751]: BDEB56499: message-id=<> Nov 3 11:13:52 machine postfix/pipe[19753]: AB1CA613A: to=<[email protected]>, relay=external, delay=0.1, delays=0.06/0/0/0.04, dsn=2.0.0, status=sent (delivered via external service)
    Nov  3 11:13:52 machine postfix/qmgr[19572]: AB1CA613A: removed
Nov 3 11:13:52 machine postfix/qmgr[19572]: BDEB56499: from=<[email protected]>, size=117, nrcpt=1 (queue active) Nov 3 11:13:52 machine postfix/pickup[19571]: CBB38613A: uid=110 from=<[email protected]> Nov 3 11:13:52 machine postfix/cleanup[19751]: CBB38613A: message-id=<> Nov 3 11:13:52 machine postfix/pipe[19753]: BDEB56499: to=<[email protected]>, relay=external, delay=0.09, delays=0.05/0/0/0.03, dsn=2.0.0, status=sent (delivered via external service)
    Nov  3 11:13:52 machine postfix/qmgr[19572]: BDEB56499: removed

How can I avoid this behavior? Once the message is modified I'd like to send it without passing it again to the filter.

Thanks again.

Reply via email to