Using Mutt to Read Spam and non-Spam Messages, and Train Spamassassin

This explains how to set up your server to go over email messages that have been rejected as spam, and then help train the Spamassassin Bayesian filter to correctly identify these messages. Spamassassin doesn't delete spam by default - it stores the messages in Maildirs, and you can then read them with Mutt (a console-based email client). You can set up Mutt to help you mark messages as spam, and use them to train the Spamassassin filter.

Spamassassin stores spam messages in Maildirs in /var/spool/sa-spam/.

To take advantage of this link that directory to your ~/Mail maildir.

ln -sf /var/spool/sa-spam/ Mail

Then put this into your .muttrc.

# Spam that SA missed is manually sent to the junkmail folder
macro index X "s=spam\n" "file as Spam"
macro pager X "s=spam\n" "file as Spam"

The X key will save messages to an mbox named spam.

You also need the spam learning program to occasionally read that file, and delete it. This was added to my learning script.

sa-learn --mbox --spam /home/johnk/Mail/spam
rm -f /home/johnk/Mail/spam

You will need to use "sudo mutt" to read the messages, because the stuff that Spamassassin saves will not be writable by your regular user account. After you get into Mutt, press 'c' to drill down into the various Spamassassin folders.

To mass-mark many messages for deletion, press "D" and then "." for the match string. That will mark everything for deletion. Deletion happens when you switch folders with "c" or quit the program with "q".