Hi Peter
would it be possible to give an example of the behaviour you're seeing
and what instead you are expecting?
Also it was unclear for me where this script is being called. Do you see
evidence (like logging) of it actually running?
John
On 17/01/2026 10:06, Peter Uetrecht via Postfix-users wrote:
Certain recipients need to be rewritten if the sender is correct.
However, the Postfix pipe daemon never rewrites the recipient.
Can anyone help me and give me a hint as to what I've overlooked or
done wrong?
Thank you in advance
Peter
Postfix 3.9.1
# postconf -c /etc/postfix -n
alias_maps = hash:/etc/aliases
command_directory = /usr/bin
compatibility_level = 3.9
config_directory = /etc/postfix/
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
inet_interfaces = localhost
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
newaliases_path = /usr/bin/newaliases.postfix
readme_directory = /usr/share/doc/postfix/README_FILES
relayhost = [192.168.2.1]:25
sample_directory = /usr/share/doc/postfix/samples
sendmail_path = /usr/bin/sendmail.postfix
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_tls_CApath = /etc/pki/tls/certs
smtp_tls_security_level = may
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.key
smtpd_tls_security_level = may
# diff /etc/postfix/master.cf.orig /etc/postfix/master.cf
<http://master.cf>
147a148,150
>
> rewritepipe unix - n n - - pipe
> flags=Rq user=nobody argv=/usr/local/bin/rewrite-envelope.sh
${sender} ${recipient}
###################### /usr/local/bin/rewrite-envelope.sh
######################
#!/bin/sh
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
SENDMAIL="/sbin/sendmail.postfix -G -i"
TMPDIR="/var/spool/postfix/rewrite"
TMPFILE="$TMPDIR/msg.$$"
trap 'rm -f "$TMPFILE"' EXIT INT TERM
cat > "$TMPFILE" || exit $EX_TEMPFAIL
ENVELOPE_FROM="$1"
shift
# Remaining arguments = recipients
RECIPIENTS="$@"
for ENVELOPE_TO in $RECIPIENTS
do
NEW_TO="$ENVELOPE_TO"
if echo "$ENVELOPE_FROM" | grep -qiP ".+@source\.dom$"
then
if echo "$ENVELOPE_TO" | grep -qiP ".+@destination\.dom$"
then
NEW_TO="[email protected]"
fi
fi
# echo "$SENDMAIL -f $ENVELOPE_FROM $NEW_TO < $TMPFILE || exit
$EX_TEMPFAIL"
$SENDMAIL -f "$ENVELOPE_FROM" "$NEW_TO" < "$TMPFILE" || exit $EX_TEMPFAIL
done
exit 0
_______________________________________________
Postfix-users mailing list [email protected]
To unsubscribe send an email [email protected]
_______________________________________________
Postfix-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]