Procmail

If you use procmail as your local
delivery agent and your email package picks up your primary mail from a
local spool file (e.g. /var/spool/mail), you will probably find
sb_filter.py the easiest application to integrate into your mail
environment.

An example setup is as follows (thanks to Alister Forbes for contributing this).
Note that the path to the sb_filter script will be the same as the prefix
you used when installing Python, which is probably /usr when you installed
Python using your OS's package management software, and is more likely to
be /usr/local if you built your own. You can refer to the output of
"setup.py install" to find the location.

Install spambayes with the usual

setup.py install

Create the database that spambayes will use to test your incoming mail:

/usr/local/bin/sb_filter.py -d $HOME/.hammie.db -n

Train it on your existing mail. This is optional, but a good idea. -g is the flag for the known good mail, and -s is for known spam

For ongoing training, there is a handy little cronjob that will run at 2:21 am every morning, training the database with good mail from Inbox and spam from caughtspam. Just add the following to your crontab