Using the CRM114 Spam filter with BincIMAP and Thunderbird

This page describes a server-side spam-filtering procedure for use with the BincIMAP server, using the CRM114 discriminator sofware.

The normal recommended CRM114 spam-training method is to forward mis-classified emails back to yourself, embedding a command sequence that tells the filter to re-classify the message. (See the CRM114 Mailfilter HOWTO.) This is awkward, and hard to explain to non-technical users. (Also, the headers usually get modified by the email client when forwarding. This is not helpful to the retraining process, since the original headers are usually full of spam-related information.)

Instead, I've written a script that scans an IMAP/maildir folder for messages to re-classify. When the user drops a message into this folder, the script determines (without requiring user input) how it was originally classified, and it issues the appropriate re-learn commands. If the new classification is "SPAM", the message is then deleted. If the new classification is "NON-SPAM", then the script calls procmail to re-deliver the message.

This script assumes that you are using procmail as the local delivery agent, and that you are using a Maildir or IMAPdir structure to store the IMAP folders. (If you are using an mbox structure instead of Maildir or IMAPdir, see John Johnston's modified mbox-enabled script instead.)

Your .procmailrc file must include something like:

:0fw: .msgid.lock
| /usr/bin/crm -u $HOME/crm114_workingdir mailfilter.crm
:0:
* ^X-CRM114-Status: SPAM.*
INBOX.checkspam/
to enable CRM114 filtering to begin with.

In $HOME/crm114_workingdir, you need to set up the standard mailfilter configuration files:

rewrites.mfp
whitelist.mfp
blacklist.mfp
scrub_mailfile_rewrites.mfp
priolist.mfp
mailfilter.cf
as well as the
mailfilter.crm
script. You also need to generate initial spam.css and nonspam.css files using:
cssutil -b -r spam.css
cssutil -b -r nonspam.css
Then set up a cron job for the root user, like
*/2 * * * * /opt/procmail-recipes/fix-spam-classification.pl > /dev/null
to run the re-classifying script every 2 minutes. The fix-spam-classification.pl perl source code is available here:

I use this set-up very successfully with the Thunderbird email client, on Windows and Linux, and the BincIMAP server.

Michael J. Chudobiak - mjc@avtechpulse.com.

Standard & customized
test solutions
since 1975

Copyright © 2024 Avtech Electrosystems Ltd, All Rights Reserved