#!/bin/sh # runfilter :- # Run the mpop filter # Check server messages against the current contents of the spam folder on this machine # If messages are in the spam folder here, delete them from the server. # Create a temp file for listing Message Ids of spam tempfoo=`basename $0` IDTMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || exit # Move to our spam folder cd /Users/sam/Library/Mail/Mailboxes/Spam.mbox/Messages/ # List Message Ids of spam on local machine into temp file awk '/[Mm]essage-[Ii][Dd]: <.+@.+>/ {print $2}' *.emlx >> $IDTMPFILE # Export location of temp file for mpop filter to use export IDTMPFILE # Run mpop with the filter script /usr/local/bin/mpop -q --filter=~/Documents/Scripts/filter echo "Done" # Cleanup after we've finished rm $IDTMPFILE