This is as days pass by, by Stuart Langridge

And this is SpamBayes and Mutt, written , and concerning Uncategorized

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:
#!/bin/bash
PYTHONPATH=$HOME/src/spambayes/spambayes $HOME/src/spambayes/spambayes/scripts/sb_filter.py -d $HOME/.hammie.db $*
Told procmail to filter my mail through SpamBayes, by putting in $HOME/.procmailrc:
PYTHONPATH=$HOME/src/spambayes/spambayes
:0fw:hamlock
| $HOME/src/spambayes/spambayes/scripts/sb_filter.py -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/null\n<save</del>message>"
macro pager s "|sb_filter <del>g -f > /dev/null\n<save</del>message>"
color index red black "~h 'X-Spambayes-Disposition: spam' ~F"

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

  1. 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. -----

Comments

Dwayne Litzenberger

Awesome. This is just what I was looking for. Thanks!

This website belongs to Stuart Langridge. Contact details are available. Don't eat yellow snow. Valid HTML5, at least in theory, except for the bits that aren't because I'm that futuristic that I'm ahead of the spec, oh yes. HTML5 help from Bruce Lawson, among others. Fonts from the superb FontSquirrel. End.