Skip to content

Instantly share code, notes, and snippets.

@rsayers
Created July 18, 2013 17:14
Show Gist options
  • Select an option

  • Save rsayers/6031105 to your computer and use it in GitHub Desktop.

Select an option

Save rsayers/6031105 to your computer and use it in GitHub Desktop.
I have a vps that does nothing but handle mail for 1 account, I needed something to block spam, but running spamd was too heavy for my vps. I run this every minute. it simply finds every mail <2 minutes old and moves it if spam assassin claims it is spam. It's low tech, but also low requirements.
#!/bin/sh
INBOX="/path/to/Maildir/cur"
SPAM="/path/to/Maildir/.spam/cur"
cd $INBOX
for i in `find ./ -type f -mmin -2`
do
echo "Testing $i"
if (cat $i | spamassassin | grep 'X-Spam-Flag..YES')
then echo "$i is spam"
mv $i $SPAM
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment