I have chosen to train DSPAM by moving the spam messages that I receive into a Junk folder in my mail client. I’ve made a small script that checks all Junk folders on the server and feeds them to DSPAM as false negatives to learn DSPAM what spam looks like. This is currently the easiest way to train DSPAM without having to rely on the web based GUI. Please note that this only works if you use IMAP folders, if your users use POP3 we have to look at another solution.
The script looks into the database of postfixadmin to see which users are defined on your system and where their mail directory is located. It then feeds every single message to DSPAM indicating it as an error and to correct DSPAM’s behaviour. After the message is processed the it is removed from the folder.
You can select which IMAP folder your want to use for storing all your SPAM including false negatives (uncaught spam) by changing this entry in the script (don’t forget the leading .):
You can define the folder where it should get the false positives (email wrongly identified as spam) in this variable (don’t forget the leading .):
Configure your postfixadmin database settings with these entries in the script:
If you want the script not to delete the identified SPAM when the email has been processed then change the DELETESPAM option in something else than YES, like NO:
The same rule is valid for the NotSpam folder. To not delete the email from the folder for false positives set this variable to NO.
If you copy the script into /etc/periodic/daily and make it executable it will run once a day and learn each users spam.
You can download my script train.dspam here
Please note that DSPAM won’t catch spam at first, you’ll need to train it first. The longer you train it the better it will get. You can use your email client junk mail controls to train DSPAM. Configure your mail client to move emails it identifies into the Junk folder. See the screenshots below on how to configure Mail.app and Thunderbird to do this.