#!/bin/sh
 
# Simple shell-based filter. It is meant to be invoked as follows:
#       /path/to/script -f sender recipients...
# Localize these. The -G option does nothing before Postfix 2.3.
 
INSPECT_DIR=/opt/zimbra/postfix/spool/filter
SENDMAIL=/usr/local/sbin/putmail.py 
MAILADMIN=admin@email.com
BADWORDS=/etc/words
 
# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
 
# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15
 
#Start processing.
cd $INSPECT_DIR || {
echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
cat >in.$$ || {
echo Cannot save mail to file; exit $EX_TEMPFAIL; }
# Specify your content filter here.
cat in.$$ | while read line; do echo $line|grep -v 'Content-Disposition: attachment;' || break; done | /bin/grep -if /etc/words  && {
echo ": The message content has been rejected, your actions have been reported" ; $SENDMAIL ${@% -- *} $MAILADMIN <in.$$ ; exit $EX_UNAVAILABLE; }
 
$SENDMAIL "$@" <in.$$
exit $?