# Maildropfilter for uni.fladi.at # Default actions to take for incoming mails # Check if Junk folder exists. # Otherwise create new one and subscribe to it. `test -d $DEFAULT/.Junk` if( $RETURNCODE == 1 ) { `/usr/bin/maildirmake -f Junk $DEFAULT` `echo INBOX.Junk >> $DEFAULT/courierimapsubscribed` } # Check for whitelist. # If none found create an empty file, otherwise lookup would fail later on. `test -r $DEFAULT/whitelist` if( $RETURNCODE == 1 ) { `/usr/bin/touch $DEFAULT/whitelist` } # Lookup sender in whitelist. # If no occurance is found in the file the mail is passed to a sequence of anti spam tools. import SENDER if (!lookup($SENDER, "$DEFAULT/whitelist")) { # Initialise SPAM marker. # 0 ... no spam # 1 ... spam SPAM=0 # Pass mail to bogofilter and update the users bogofilter-db. # Bogofilter adds an extra header indication its suggestion whether the mailis spam or ham. exception { xfilter "/usr/bin/bogofilter -u -e -p" if (/^X-Bogosity: Spam/) { # Spam detected. Set marker to 1. SPAM=1 } } # Pass mail to spamassassin. # Spamassassin adds an extra header indication its suggestion whether the mailis spam or ham. exception { xfilter "/usr/bin/spamc" if (/^X-Spam-Flag: YES/) { # Spam detected. Set marker to 1. SPAM=1 } } # Pass mail to razor. # Razor is deactivated due to errors in MIME handling. #exception { # cc "|/usr/bin/razor-check" # if ($EXITCODE == 0) # { # xfilter "/usr/bin/reformail -A'X-Razor: Spam'" # EXITCODE=0 # # Spam detected. Set marker to 1. # SPAM=1 # } # else # { # xfilter "/usr/bin/reformail -A'X-Razor: Ham'" # EXITCODE=0 # } #} # Pass mail to pyzor. # Pyzor indicates its result by passing a return value of 0 which indicates spam. exception { cc "|/usr/bin/pyzor check" if ($EXITCODE == 0) { xfilter "/usr/bin/reformail -A'X-Pyzor: Spam'" EXITCODE=0 # Spam detected. Set marker to 1. SPAM=1 } else { xfilter "/usr/bin/reformail -A'X-Pyzor: Ham'" EXITCODE=0 } } # Pass mail to DCC. # DCC is deactivated because it indicates too much false positives. #exception { # cc "|/usr/bin/dccproc -Rw whiteclnt -c CMN,25 >/dev/null" # if ($EXITCODE == 67) # { # EXITCODE=0 # xfilter "/usr/bin/reformail -A'X-DCC: Spam'" # SPAM=1 # } # else # { # xfilter "/usr/bin/reformail -A'X-DCC: Ham'" # EXITCODE=0 # } #} # If SPAM marker has been set to 1 by any of the above tests push the mail into the appropriate folder. # To track detected Spam there's an "echo" statement which writes to syslog. if ($SPAM == 1) { echo "Spam detected!" to "$DEFAULT/.Junk" } } # Check if vacation has been set for this user. `test -f .vacation.msg` if ($RETURNCODE == 0) { # Vacation file found. # Answer mail with /usr/bin/vacation. cc "|/usr/bin/vacation $LOGNAME" xfilter "/usr/bin/reformail -A'X-Vacation: Sent'" } # All done. If mail has not been deliverd yet, drop it into the regular inbox.