Multiple after-queue content filters

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple after-queue content filters

Sig Pam
Multiple after-queue content filters

Hello community!


The current documentation states:


   The "-o content_filter" line causes Postfix to add one content filter request record to each incoming mail message ...


Q1: Is it still true you can not give a list of content filters which are processed one after the other?



Q2: Assuming this is still true and content_filter does not take a list of filters, is there a better technique than creating a "wrapper script" to call the multiple filters one after the other?


Background: I currently pipe my mail to spamassassin, but I also want to call a program adding a boilerplate for each outgoing mail (legal reason), and I think about a script which modifies incoming mails to strip html links to prevent my users clicking on them. These are three filters which should run on each mail.



Bonus question: I can configure a content_filter for each service defined in master.cf, but there is also a parameter content_filter in main.cf. What does the latter refer to, and in which order are they processed? I'm confused ...


Thank you!


Sig


###############

current configuration:

###############


master.cf:


[...]

smtp       inet  n       -       y       -       -       smtpd
        -o content_filter=spamassassin

[...]

spamassassin unix - n n - - pipe
        user=spamd argv=/usr/bin/spamc --max-size 5242880 -d 127.0.0.1 -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}




main.cf:

[...]

content_filter = smtp-<a href="amavis:127.0.0.1:10024" target="_blank" title="amavis:127.0.0.1:10024 Klicken Sie auf den Link, um die URL in einem neuen Fenster zu öffnen." rel="noreferrer noopener">amavis:127.0.0.1:10024

[...]




Reply | Threaded
Open this post in threaded view
|

Re: Multiple after-queue content filters

Matus UHLAR - fantomas
On 05.02.20 11:47, Sig Pam wrote:
>The current documentation <http://www.postfix.org/FILTER_README.html> states:
>
>   The "-o content_filter" line causes Postfix to add one content filter request record to each incoming mail message ...
>
>Q1: Is it still true you can not give a list of content filters which are
> processed one after the other?

it doesn't make sense. content filter is expected to push mail  back to
postfix other way, so message can't get to second filter.

>Q2: Assuming this is still true and content_filter does not take a list of
> filters, is there a better technique than creating a "wrapper script" to
> call the multiple filters one after the other?

you can create filter chain in postfix by pushing mail to multiple ports
each having own filter.

>Background: I currently pipe my mail to spamassassin, but I also want to
> call a program adding a boilerplate for each outgoing mail (legal reason),
> and I think about a script which modifies incoming mails to strip html
> links to prevent my users clicking on them.  These are three filters which
> should run on each mail.
>
>Bonus question: I can configure a content_filter for each service defined
> in master.cf, but there is also a parameter content_filter in main.cf.
> What does the latter refer to, and in which order are they processed?  I'm
> confused ...

options in master.cf are used to override those in main.cf.
if you don't override it in master.cf for a service, that service uses
main.cf value.

>smtp       inet  n       -       y       -       -       smtpd
>        -o content_filter=spamassassin
>
>spamassassin unix - n n - - pipe
>        user=spamd argv=/usr/bin/spamc --max-size 5242880 -d 127.0.0.1 -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

>main.cf:

>content_filter = smtp-amavis:127.0.0.1:10024

apparently amavis is only used when receiving mail other way than smtp (on
port 25).

--
Matus UHLAR - fantomas, [hidden email] ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Linux IS user friendly, it's just selective who its friends are...
Reply | Threaded
Open this post in threaded view
|

Re: Multiple after-queue content filters

Wietse Venema
In reply to this post by Sig Pam
Sig Pam:
> Hello community!
>
> The current documentation <http://www.postfix.org/FILTER_README.html> states:
>
> ?? The "-o content_filter" line causes Postfix to add one content filter request record to each incoming mail message ...
>
> Q1: Is it still true you can not give a list of content filters which are processed one after the other?

After Postfix gives the message to the content filter, the filter
can do all kinds of things. It can give the message to another
content filter (for example over SMTP), or send the message to
Postfix, or send the message to a different MTA, or it can even
discard the message. Those are all valid actions. There is no need
for Postfix trying to be clever and get in the way of things.

In particular with SMTP-based filters, there is no need for clumsy
wrapper scripts. Simply configure each filter to send the result
to their successor's SMTP port.

        Wietse
Reply | Threaded
Open this post in threaded view
|

AW: Multiple after-queue content filters

Sig Pam
AW: Multiple after-queue content filters
Sig Pam:
> Hello community!
>
> The current documentation <http://www.postfix.org/FILTER_README.html> states:
>
> ?? The "-o content_filter" line causes Postfix to add one content filter request record to each incoming mail message ...
>
> Q1: Is it still true you can not give a list of content filters which are processed one after the other?

After Postfix gives the message to the content filter, the filter
can do all kinds of things. It can give the message to another
content filter (for example over SMTP), or send the message to
Postfix, or send the message to a different MTA, or it can even
discard the message. Those are all valid actions. There is no need
for Postfix trying to be clever and get in the way of things.

In particular with SMTP-based filters, there is no need for clumsy
wrapper scripts. Simply configure each filter to send the result
to their successor's SMTP port.

Wietse


Thank you, Wietse. Got it.


Would you mind clarifying on the difference between content_filter in the service descriptions in main.cf versus the parameter content_filter in master.cf? They both refer to the same documentation, but they both are used. Is there some priorisation? What's the difference?


Thank you.


Sig

Reply | Threaded
Open this post in threaded view
|

AW: Multiple after-queue content filters

Sig Pam
In reply to this post by Matus UHLAR - fantomas
AW: Multiple after-queue content filters
On 05.02.20 11:47, Sig Pam wrote:
>The current documentation <http://www.postfix.org/FILTER_README.html> states:
>
>   The "-o content_filter" line causes Postfix to add one content filter request record to each incoming mail message ...
>
>Q1: Is it still true you can not give a list of content filters which are
> processed one after the other?

it doesn't make sense. content filter is expected to push mail back to
postfix other way, so message can't get to second filter.

>Q2: Assuming this is still true and content_filter does not take a list of
> filters, is there a better technique than creating a "wrapper script" to
> call the multiple filters one after the other?

you can create filter chain in postfix by pushing mail to multiple ports
each having own filter.

>Background: I currently pipe my mail to spamassassin, but I also want to
> call a program adding a boilerplate for each outgoing mail (legal reason),
> and I think about a script which modifies incoming mails to strip html
> links to prevent my users clicking on them. These are three filters which
> should run on each mail.
>
>Bonus question: I can configure a content_filter for each service defined
> in master.cf, but there is also a parameter content_filter in main.cf.
> What does the latter refer to, and in which order are they processed? I'm
> confused ...

options in master.cf are used to override those in main.cf.
if you don't override it in master.cf for a service, that service uses
main.cf value.

>smtp       inet  n       -       y       -       -       smtpd
>        -o content_filter=spamassassin
>
>spamassassin unix - n n - - pipe
>        user=spamd argv=/usr/bin/spamc --max-size 5242880 -d 127.0.0.1 -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

>main.cf:

>content_filter = smtp-amavis:127.0.0.1:10024

apparently amavis is only used when receiving mail other way than smtp (on
port 25).


Awesome answer, thank you very much. No more questions.


Cheers


Sig

Reply | Threaded
Open this post in threaded view
|

Re: AW: Multiple after-queue content filters

Wietse Venema
In reply to this post by Sig Pam
Sig Pam:
> Thank you, Wietse. Got it.
>
> Would you mind clarifying on the difference between content_filter
> in the service descriptions in main.cf versus the parameter
> content_filter in master.cf? They both refer to the same documentation,
> but they both are used. Is there some priorisation? What's the
> difference?

It's explained in http://www.postfix.org/master.5.html. Those
settings take precedence over main.cf (the opposite order would
not be useful).

        Wietse