On 2/10/2022 1:50 PM, Edward Sandberg wrote:
I am attempting to configure content filtering by following this guide:

http://www.postfix.org/FILTER_README.html

I have added the filter service and modified the smtp service in master.cf:

filter    unix  -       n       n       -       10      pipe
     flags=Rq user=filter null_sender=
     argv=/home/filter/filter.sh -f ${sender} -- ${recipient}
smtp      inet  n       -       y       -       -       smtpd
     -o content_filter=filter:dummy


The above is correct. The content_filter setting is applied to mail arriving via the smtpd listener on port 25.

and reloaded postfix. When that didn't work I tried editing master.cf.proto instead but still no change in behavior. I also tried adding the filter option to these services:

smtp      unix  -       -       y       -       -       smtp
     -o content_filter=filter:dummy
relay     unix  -       -       y       -       -       smtp
         -o syslog_name=postfix/$service_name
     -o content_filter=filter:dummy

but no joy.

This is incorrect. The content_filter parameter has no effect on the "smtp" delivery transport.


The mail is being sent but the filter is not being used. I can delete the filter script, mail still gets sent and no difference in behavior occurs. I would expect some kind of error if the filter script can't be found so I think its not even trying to use the filter.

A more careful reading of the "simple content filter example" will reveal:

"This means that mail submitted via the Postfix sendmail(1) command cannot be content filtered."



When I run the following command:

echo  "body of your email" | mail -s "This is a subject too" -a "From:redac...@redacted.com" redac...@redacted.com

This uses the sendmail command.


This is the syslog outout I see:

Feb 10 19:39:03 postfix postfix/pickup[13850]: 7D1D0E0E6F: uid=0 from=<redac...@redacted.com> Feb 10 19:39:03 postfix postfix/cleanup[13903]: 7D1D0E0E6F: message-id=<20220210193903.7d1d0e0...@postfix.redacted.net> Feb 10 19:39:03 postfix postfix/qmgr[13849]: 7D1D0E0E6F: from=<redac...@redacted.com>, size=393, nrcpt=1 (queue active) Feb 10 19:39:04 postfix postfix/smtp[13905]: 7D1D0E0E6F: to=<redac...@redacted.com>, relay=ASPMX.L.GOOGLE.com[173.194.219.26]:25, delay=0.61, delays=0.03/0.03/0.24/0.31, dsn=2.0.0, status=sent (250 2.0.0 OK 1644521944 i1si9676536ybt.537 - gsmtp)
Feb 10 19:39:04 postfix postfix/qmgr[13849]: 7D1D0E0E6F: removed

What am I missing?

To test your existing filter, submit mail via SMTP on port 25. If you intend to filter mail submitted via the command line sendmail, you will need an Advanced Content Filter or milter.



  -- Noel Jones

Reply via email to