These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes
Classnotes | UNIX03 | RecentChanges | Preferences
No diff available--this is the first major revision.
(no other diffs)
One of the last steps we need to do is setup our SpamAssassin learning system. As you've seen SA will automatically add very SPAMMY or NOT-SPAMMY messages to its Bayesian database. In addition to that, we want to give our users the opportunity to help fine-tune the system. Remember the spam and notspam accounts that we setup earlier? Well this is where we put them to use.
First, a little explanation. When a user sends an email message to email@example.com (substitute your server's name), it will be delivered to a single mbox file, in this case /var/mail/spam. Mail to firstname.lastname@example.org will be delivered to /var/mail/notspam. Once a day (or more if you want), we want the system to read in all the email in these mbox files and add them to the Bayesian statistics database. To accomplish this, we'll write a script and call it using cron.
Create a file using your text editor and call it /usr/local/sbin/my-sa-learn.sh. Cut and paste the following commands into this file:
if [ -e /var/mail/spam ]; then
/usr/bin/sa-learn --spam -p /var/lib/amavis/.spamassassin/user_prefs --mbox /var/mail/spam
rm /var/mail/spam > /dev/null
if [ -e /var/mail/notspam ]; then
/usr/bin/sa-learn --ham -p /var/lib/amavis/.spamassassin/user_prefs --mbox /var/mail/notspam
rm /var/mail/notspam > /dev/null
/usr/bin/sa-learn --rebuild -p /var/lib/amavis/.spamassassin/user_prefs
Now run the following command to make it executable:
# chmod 500 /usr/local/sbin/my-sa-learn.sh
Next, we want to add it to our list of list of scheduled programs.
# crontab -e
Add the following 2 lines at the bottom of the file:
# spamassassin bayesian learning script
05 0 * * * /usr/local/sbin/my-sa-learn.sh
This will cause the script to get run every night at 12:05 am.