I currently use Postfix with SpamAssassin, Anomy, and a custom content filter that associates emails with certain records in a contact database based on certain criteria in the Subject.

With Zimbra the only thing that I would need to add is my own custom piece, but I can't seem to get it to work.

In the existing system I set :content_filter=spamfilter:

spamfilter unix - n n - - pipe
flags=Rq user=filter argv=/usr/local/bin/filter.sh -f ${sender} -- ${recipient}


I can get the Postfix in Zimbra to execute but it always fails with an error message generated by my script. Basically the execution back into the smtp process fails.

I believe that it is failing at the $SENDMAIL command, Probably because of the pipe(?):

SENDMAIL="/usr/sbin/sendmail -i"
ANOMY=/opt/zimbra/anomy
ANOMY_CONF=/opt/zimbra/anomy/sanitizer.cfg
ANOMY_LOG=/dev/null
SPAMC=/usr/bin/spamc
DOC=/opt/zimbra/anomy/mail.pl

export ANOMY

# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

cat | $DOC \
| $ANOMY/bin/sanitizer.pl $ANOMY_CONF 2>>$ANOMY_LOG \
| $SENDMAIL "$@" || \
{ echo Message content rejected; exit $EX_UNAVAILABLE; }

exit $?


fyi this script works via the command line by executing it outside of the MTA:

cat spool/test.txt | /opt/zimbra/anomy/filter.sh -f root@theinsitegroup.com -- jmcknight@theinsitegroup.com

Ideas?