Hi John,
it works, thank you very much for putting me on the right track.
The email is now delivered by the Pipe daemon to the filter script,
which then re-injects the message to Postfix via sendmail command.
> What isn't clear to me is whether it also receives email via sendmail
apart from your script and that email from sendmail has to be filtered.
> Bit if you are not planning to filter email arriving via sendmail
command You may fit into the scenario that is described here:
> https://www.postfix.org/FILTER_README.html
Only email not received via sendmail command should be rewritten if a
match is found.
> in the section "Simple content filtering". If so that would require
you to make a configuration update in master.cf for the smtp service
adding the parameter "
>
>
> -ocontent_filter
>
<https://www.postfix.org/postconf.5.html#content_filter>=rewritepipe:dummy
I added "-o content_filter=rewritepipe:dummy" to master.cf
# diff /etc/postfix/master.cf.orig /etc/postfix/master.cf
12c12
< smtp inet n - n - - smtpd
---
> smtp inet n - n - - smtpd -o
content_filter=rewritepipe:dummy
147a148,150
>
> rewritepipe unix - n n - 10 pipe
> flags=Rq user=filter null_sender=
argv=/usr/local/bin/rewrite-envelope.sh ${sender} ${recipient}
On 1/17/26 1:22 PM, John Fawcett via Postfix-users wrote:
On 17/01/2026 11:46, Peter Uetrecht via Postfix-users wrote:
Hi John,
I expect emails from senders with the domain [email protected] addressed
to recipient [email protected] to be rewritten to recipient
[email protected]. I can't find any evidence that the Postfix pipe
daemon called the script, and therefore Sendmail can't resend the
email with a rewritten recipient. This is all I find in the logs, no errors.
Jan 17 10:45:19 pc postfix/smtpd[282165]: 08DDE196C31:
client=localhost[127.0.0.1]
Jan 17 10:45:37 pc postfix/cleanup[282170]: 08DDE196C31:
message-id=<[email protected]>
Jan 17 10:45:37 pc postfix/qmgr[282063]: 08DDE196C31:
from=<[email protected]>, size=412, nrcpt=1 (queue active)
Jan 17 10:45:37 pc postfix/smtp[282171]: 08DDE196C31:
to=<[email protected]>, relay=192.168.2.1[192.168.2.1]:25,
delay=29, delays=29/0.03/0.02/0, dsn=2.0.0, status=sent (250 ok:
Message 239712885 accepted)
Jan 17 10:45:37 pc postfix/qmgr[282063]: 08DDE196C31: removed
Jan 17 10:45:38 pc postfix/smtpd[282165]: disconnect from
localhost[127.0.0.1] helo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Hi Peter
you want to filter emails and you have defined a transport in
master.cf that will do that, but it looks like you are not actually
directing email into that transport.
In the example above, email is arriving via smtp from the localhost
and is correctly being delivered as per the relayhost setting.
In order to use your filter you will need to direct email to it in
some way. There could be multiple ways of achieving that, depending on
the exact scenario of this postfix server. It seems that the server
does not have any local recipients and that it receives email via
smtp. It also is expected to receive email via sendmail from your
filter script. What isn't clear to me is whether it also receives
email via sendmail apart from your script and that email from sendmail
has to be filtered. Of course the email from your script must not be
filtered else it would create a loop.
Bit if you are not planning to filter email arriving via sendmail
command You may fit into the scenario that is described here:
https://www.postfix.org/FILTER_README.html
in the section "Simple content filtering". If so that would require
you to make a configuration update in master.cf for the smtp service
adding the parameter "
-ocontent_filter
<https://www.postfix.org/postconf.5.html#content_filter>=rewritepipe:dummy
and reload postfix.
John
_______________________________________________
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]