Discussion:
Using a custom filter via script to reject inbound email
(too old to reply)
d***@googlemail.com
2016-11-25 14:47:13 UTC
Permalink
Hi -

I'm trying to find my way around postfix config & customisation and am stuck.

Is there any way in postfix to execute a script and capture the result (0 or 1), then based on that result accept or reject inbound email?

I'd already asked the question here on stack exchange which has more detail about the scenario:
https://unix.stackexchange.com/questions/325407/using-a-custom-filter-via-script-to-reject-inbound-email

I was looking at before queue filtering but can't see a way of capturing the result of a script exec.

Thanks

Rex
d***@gmail.com
2017-01-21 13:01:10 UTC
Permalink
Post by d***@googlemail.com
Hi -
I'm trying to find my way around postfix config & customisation and am stuck.
Is there any way in postfix to execute a script and capture the result (0 or 1), then based on that result accept or reject inbound email?
https://unix.stackexchange.com/questions/325407/using-a-custom-filter-via-script-to-reject-inbound-email
I was looking at before queue filtering but can't see a way of capturing the result of a script exec.
Thanks
Rex
Hi

Yes there is a way.

A before queue filtering is when the smtp client is still connected so you could send SMTP code but if you want an external script you have to do a "Postfix After-Queue Content Filter "

You can find more information here :
http://www.postfix.org/FILTER_README.html

This is the idea :

incoming mail -> postfix:25 -> external script -> postfix:10025 -> outgoing mail

The external script do not answer 0 or 1 but a normalised exit code like theses :
EX_OK 0 /* successful termination : transmit */
EX_UNAVAILABLE 69 /* service unavailable : bounce */
EX_SOFTWARE 70 /* internal software error : bounce */
EX_TEMPFAIL 75 /* temp failure. postfix will retry. */
EX_NOPERM 77 /* permission denied : bounce */


Regards

Victor d'Agostino

Loading...