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"
- 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. -----
Awesome. This is just what I was looking for. Thanks!