SpamBayes and Mutt

So I got 400 spams the other day. This finally convinced me that my “just delete them, it doesn’t take long” policy doesn’t work. Something better is required. Now, I use SpamBayes at work (Windows shop, so I like the Outlook plugin), and thought I’d use it at home too. I use mutt as my mail client. So, here’s what I’ve done so far: Installed procmail: apt-get install procmail Got spambayes: download and unpack the archive into $HOME/src/spambayes Created a sb_filter shell script that invokes SpamBayes’ filter:

PYTHONPATH=$HOME/src/spambayes/spambayes $HOME/src/spambayes/spambayes/scripts/ -d $HOME/.hammie.db $*

Told procmail to filter my mail through SpamBayes, by putting in \$HOME/.procmailrc:

| $HOME/src/spambayes/spambayes/scripts/ -d $HOME/.hammie.db

Set up keybindings for mutt: I use “s” to save the current message into a folder, and I never save spam into a folder, so I want to train any saved message as ham (non-spam). I bind “S” to mean “this is spam, so train it as spam and then delete it“. In .muttrc:

## Lower case s saves the message after training it as ham.
    ## Upper-case S deletes the message after training it as spam.

    macro index s "|sb_filter <del>g -f > /dev/nulln<save</del>message>"
macro pager s "|sb_filter <del>g -f > /dev/nulln<save</del>message>"
color index red black "~h 'X-Spambayes-Disposition: spam' ~F"

    macro index S "<delete-message>|sb_filter -s -f > /dev/nulln"
macro pager S "<delete-message>|sb_filter -s -f > /dev/nulln"

    Stop Mutt saying "Press any key to continue" after training
set wait_key=no

And that’s it. I still have to delete all my spam, but now SpamBayes is learning what spam is. Once I’ve been doing this for a little while, I’ll alter my .procmailrc (as dictated on the SpamBayes site) to automatically file spam in a “spam” folder.

More in the discussion (powered by webmentions)

  • (no mentions, yet.)