Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PCRE header_check Content Filter bounces

84 views
Skip to first unread message

redic...@gmail.com

unread,
Mar 31, 2016, 6:13:29 AM3/31/16
to
Hi

I am trying to make a content filter via pcre:header_checks but reinjecting the mail with sendmail command reexecutes the filter again and again and I have a bounce. Has anyone an idea why Postfix is behaving like this?

master.cf:
smtp inet n - n - - smtpd
-o content_filter=spamassassin
# Header check filter To:
header_checks_to unix - n n - - pipe
flags=qR user=filter argv=/etc/postfix/header_checks_to.sh ${sender} ${recipient}
# Spamassassin
spamassassin unix - n n - - pipe
user=debian-spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}



main.cf:
header_checks = pcre:/etc/postfix/header_checks



header_checks:
# Header Check To Filter
/^To:.*@runlevel\.ch\b/ FILTER header_checks_to:dummy



header_checks_to.sh:
#!/bin/bash

SENDMAIL="/usr/sbin/sendmail -i -G"
TEMPFILE="/tmp/in.$$"

trap "rm -rf $TEMPFILE" 0 1 2 3 15

cat >$TEMPFILE

logger -p mail.info -t filter "$0 $@ executed"

$SENDMAIL "$@" <$TEMPFILE

exit $?


d.agosti...@gmail.com

unread,
Apr 1, 2016, 9:43:30 AM4/1/16
to
Hi

You have a loop because you reinject each time on port 25 and then the mail go to the "pipe" postfix service.

So you need to stop using "pipe" and reinject the mail in a different port. This port, 10025 for exemple, will have to be linked to a smtpd instance without filtering in master.cf. Remember in master.cf the keyword "smtp" in the begining of the lines means "port tcp 25".

smtp inet n - n - - smtpd
-o content_filter=myfilter.sh


10025 inet n - n - - smtpd
-o content_filter=


Your myfilter.sh must be modified to call spamassassin and do the header checks.

In addition, I think sendmail don't let you choose the port but you can use msmtp instead which is excellent.
http://msmtp.sourceforge.net/download.html

Regards

Victor
0 new messages