Dovecot plugin for SpamAssassin training

This is a Dovecot plugin that makes it more convenient to train SpamAssassin. It is entirely based on a similar plugin for dSPAM by Johannes Berg. This version has been tested with Dovecot beta8.

The software assumes that every user has a dedicated IMAP folder that spam gets directed to. The plugin watches for mail that gets moved into or out of this folder. Every time a piece of mail is moved into the spam folder, SpamAssassin will re-learn that email as spam. Every time a piece of mail is moved out of the spam folder, SpamAssassin will re-learn that email as "ham." In order to train SpamAssassin, it is only necessary to find the emails that were classified incorrectly and move them. In my case, I use an Outlook client at work and it sometimes recognizes spam that got past SpamAssassin. When that happens Outlook automatically moves the mail into the spam folder and SpamAssassin then automatically learns from it.

This is a similar approach as used by other learning systems. It is just modified to make it easier for email users. In my opinion, moving an email into a spam folder is simpler than copying it and placing the copy into a special folder that has been created just for training. The implementation of this plugin can slow down the mail server enough that it may not be appropriate for organizations with a large user base.

The source code and brief documentation are in the file below.