#!/bin/sh # # Filter Script used by mpop to determine if we want to delete # or keep the message currently being looked at on the server. # # It does this by looking for a matching message-id in a temp file # listing all message-ids of messages in the spam mailbox on the local machine. # This list should have already been generated by 'runfilter' the script that # invoked mpop with this filter. # Get the Message Id of the message passed by mpop SRVMSGID=`awk '/[Mm]essage-[Ii][Dd]: <.+@.+>/ {print $2}'` # No message-id, so we can't compare if [ -z "$SRVMSGID" ]; then echo "Keep No Message ID" exit 2 fi # Search for passed message-id in temp file with all local spam messages-ids within it. # Only return count of number found. PRESENT=`fgrep -c "${SRVMSGID}" $IDTMPFILE` # At least one spam message matches the one from the server we're looking at, # so return a delete result to mpop. if [ $PRESENT -gt 0 ]; then echo "Delete $SRVMSGID" exit 1 else # The message we're looking at isn't in the spam list, so leave it on the server. echo "Keep $SRVMSGID" exit 2 fi