El 2017-11-03 11:05, wie...@porcupine.org escribió:
Noel Jones:
On 11/2/2017 7:48 AM, nico...@devels.es 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
> r...@internal-domain.com by default, but if the recipient is
> u...@external-domain.com I want to rewrite sender to be
> r...@different-domain.com.
>
> 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: r...@original-domain.com/From:
r...@modified-domain.com/' <<< "$content")
TMPFILE=`mktemp`
echo $contfin > $TMPFILE
cat $TMPFILE | /usr/sbin/sendmail -G -i -f r...@modified-domain.com
-- $1
/bin/rm -f $TMPFILE
exit $?
In transports map file (postmapped):
destinar...@user.com 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=<20171103111352.965731...@machine.stic.ull.es>
Nov 3 11:13:52 machine postfix/qmgr[19572]: 965731DA9:
from=<r...@original-domain.com>, size=307, nrcpt=1 (queue active)
Nov 3 11:13:52 machine postfix/pickup[19571]: AB1CA613A: uid=110
from=<r...@modified-domain.com>
Nov 3 11:13:52 machine postfix/cleanup[19751]: AB1CA613A:
message-id=<>
Nov 3 11:13:52 machine postfix/pipe[19753]: 965731DA9:
to=<destinat...@user.com>, 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=<r...@modified-domain.com>, size=117, nrcpt=1 (queue active)
Nov 3 11:13:52 machine postfix/pickup[19571]: BDEB56499: uid=110
from=<r...@modified-domain.com>
Nov 3 11:13:52 machine postfix/cleanup[19751]: BDEB56499:
message-id=<>
Nov 3 11:13:52 machine postfix/pipe[19753]: AB1CA613A:
to=<destinat...@user.com>, 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=<r...@modified-domain.com>, size=117, nrcpt=1 (queue active)
Nov 3 11:13:52 machine postfix/pickup[19571]: CBB38613A: uid=110
from=<r...@modified-domain.com>
Nov 3 11:13:52 machine postfix/cleanup[19751]: CBB38613A:
message-id=<>
Nov 3 11:13:52 machine postfix/pipe[19753]: BDEB56499:
to=<destinat...@user.com>, 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.