Theoretical part:

Before you start to use bmf it is a good thing to know a little bit about the theoretical background of Bayesian spamfiltering.

Training bmf:

Lets take a look at this basic .procmailrc example.

:0fw
* < 256000
| bmf -p

:0e
{
EXITCODE=$?
}

:0:
* ^X-Spam-Status: Yes
zspam # This is the mailbox where all spam goes.

:0w
inbox # This is your inbox

bmf will now sort your mail in a spam and non-spam folder. Training bmf means you have to tell it when it has made a mistake. As an example you can add these shortcuts to your .muttrc

macro index <f3> "|bmf -S\n<save-message>=zspam\n" "SPAM"
macro index <f4> "|bmf -N\n<save-message>=inbox\n" "NOT SPAM"
macro pager <f3> "|bmf -S\n<save-message>=zspam\n" "SPAM"
macro pager <f4> "|bmf -N\n<save-message>=inbox\n" "NOT SPAM"

Now you can press the F3 button to tell bmf a message in your inbox is spam ( bmf -S ) and move it to your spam-folder. If you find a non-spam message in your spam-folder you can press F4 and bmf will unregister the message as spam and put it in your normal mailfolder.

Feeding a spam-archive to bmf:

To speed up the process of feeding the bmf-database you can also download a recent spam archive and run the files in the archive through the following one-liner:

for i in * ; do bmf -s -i $i; done

This method is not recommended by the author since the headers of a message are also taken in account. And the headers of the messages from a spam-archive do not match yours. But I had good results with this method.

Mixing with SpamAssassin:

You can also mix bmf with SpamAssassin. bmf is much lighter than spamassassin but SpamAssassin does not have to be trained. You can actually use SpamAssassin to train bmf. Change your .procmailrc to something like this:

:0fw
* < 256000
| bmf -p

:0e
{
EXITCODE=$?
}

:0:
* ^X-Spam-Status: Yes
zspam-bmf


:0fw
* < 256000
| spamc -p 4321 -f

:0e
{
EXITCODE=$?
}

:0:
* ^X-Spam-Status: Yes
{
  :0c
  | spamassassin -d | bmf -S
  :0
  zspam-sa
}

:0w
inbox

All spam caught by bmf will be send to the zspam-bmf folder. All spam missed by bmf but caught by SpamAssassin will be fed to bmf for training and then send to the zspam-sa folder.

Disclaimer:

If anything bad happens to your email I am not responsible. If you have any improvements to this document please send them to the maintainer of this port.