On 10/16/2017 10:15 AM, Mickael DEQUIDT wrote: > Hi everyone, > > in trying to tinker a little with my postfix, I stumbled on an issue > regarding filtering with header_checks. > > I am trying to filter a few emails according to their From: header > (and not their envelope-from). So, basically, what I did was to add > a header_checks in my main.cf, like this : > > /^From:(.*)<someone@domain\.com>/ FILTER prog:dummy > > like it is told in http://www.postfix.org/FILTER_README.html > And in master.cf : > > prog unix - n n - 10 pipe > flags=Rq user=filter argv=/etc/postfix/filtre_spam -f ${sender} -- > ${recipient} > > > My prog is quite like the shell script given in example. However, I > soon realized that it was no good, for an infinite loop was being > created when prog was sending the email back with sendmail. > > Which is why I read the second part of the doc, about advanced > content filtering. I created a new service in master.cf, just like > the doc, to reinject the mail back to postfix in a way that would > stop the header_checks : > > localhost:10026 inet n - n - 10 smtpd > -o content_filter= > -o > receive_override_options=no_unknown_recipient_checks,no_header_body_checks,no_milters > > -o smtpd_helo_restrictions= > -o smtpd_client_restrictions= > -o smtpd_sender_restrictions= > -o smtpd_relay_restrictions= > -o smtpd_recipient_restrictions=permit_mynetworks,reject > -o mynetworks=127.0.0.0/8 > -o smtpd_authorized_xforward_hosts=127.0.0.0/8 > > > Now what I don't understand, is how to call my prog in > header_checks, and have it reinject the mail through > localhost:100026 ? The example given in > http://www.postfix.org/FILTER_README.html filters everything, and it > is noted in the end of the page that it can be used with > header_checks, but I don't understand how. > > I've tried putting : > > > /^From:(.*)<someone@domain\.com>/ FILTER prog:localhost:10026 > > in header_checks, but to no avail. > > Could you please enlighten me as to how to proceed ? > >
To use as an advanced content filter, your prog must be able to talk SMTP. A simple way to do this might be to use a command line SMTP agent such as "mini_sendmail" rather than the sendmail command. Other - and more robust - solutions would to use a more sophisticated filter program that accepts mail over SMTP. amavisd-new is an example of this. -- Noel Jones