SpamAssassin is a tool to remove Spam from incoming email. The following describes a way of training Spam Assassin to be more effective.
Email is stored within Cyrus, and mail that gets through SpamAssassin into a user's inbox is then moved to the "put_spam_here" folder by the user.
This script is run hourly, empties the "put_spam_here" folder, and hopefully trains spamassassin to catch more spam.
#!/bin/bash
PATH=/bin:/usr/bin:/usr/sbin:/sbin
export PATH
set -e #set -x
if [ -d /tmp/assassin ]; then
echo "erk.. /tmp/assassin exists"
exit 2
fi
trap "/bin/rm -Rf /tmp/assassin" EXIT SIGKILL SIGTERM SIGQUIT
mkdir -p /tmp/assassin
found=no
for f in /var/spool/cyrus/mail/p/put_spam_here/*
do
if echo $f | grep "[0-9]" > /dev/null
then
# echo "Spam to fry"
found=yes
fi
done
if [ $found != "yes" ]
then
# echo "nothing to fry"
exit 0
fi
for f in /var/spool/cyrus/mail/p/put_spam_here/[0-9]*
do
mv $f /tmp/assassin/
done
su - cyrus -c "/usr/sbin/cyrreconstruct put_spam_here >/dev/null"
for f in /tmp/assassin/*
do
/usr/bin/sa-learn --spam $f >/dev/null
done
Comments
Post new comment