This is a bit rough yet. Sorry. WARNING: I have been using a system like this one for about two months with good success. However, this code if somewhat different than what I am currently using and hasn't get been well tested. Be careful. Install the spambayes package. Create a new qmail user "qmailf" that is in the group "qmail". Setup the filter directory: $ umask 022 $ mkdir /var/qmail/filter $ cd /var/qmail/filter $ mkdir info messages $ mkfifo input $ mkfifo status $ chown -R qmailf.qmail . $ chmod g+w input Train a DB: $ /mailsort.py -t -d wordprobs.cdb ham.mbox spam.mbox Create a whitelist (you should add hosts that legitimately forward mail to you): $ touch whitelist.txt Run qspambayes.py as qmailf as a daemon. Patch qmail-queue.c and replace /var/qmail/bin/qmail-queue with patched version. If qspambayes.py dies then qmail-queue will hang until it is restarted. whitelist.txt and wordprobs.cdb can be replaced without stopping qspambayes.py (e.g. make a new version and move it in place). You can use show_delayed.py to view messages that have been temporarily rejected.