Richard
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:
DBPASS=yourpassword
DB=postfix
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 the 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.


Next step: Adding a delivery filter – maildrop



Comments
6:28 pm
Richard,
I get many good email messages, especially from a new contact, marked as SPAM. Even though there is a .NoSpam directory, I don’t have a NoSpam folder in Thunderbird. How do I deal with falsely identified spam?
9:09 pm
Are you sure you are suscribed to the NoSpam folder in Thunderbird, does it show up in Mail.app ? If not please create it using Thunderbird and see where it ends up in your virtual folder ti see if any mistakes where made.
11:05 pm
It was the subscription. Thank you
12:33 am
I have a question about your script and this $ :
$MAILDIR
Where and how this path is definied ?
$MAILDIR is definied from (by reading) USERFILE=/tmp/dspam.users ?
I’m trying to adapt this script for my installation, but I have “/home/vmail/$domain/$username/Maildir/$spamfolder/cur” and “/home/vmail/$domain/$username/Maildir/$spamfolder/new”.
And my “/tmp/dspam.users” file look like that :
somedomain.net postmaster
anotherdomain.com postmaster
anotherdomain.com someusername
It’s enought to be understood by your script by your line ? => “$VIRTUAL_BASE$MAILDIR$SPAM_VIRTUAL_FOLDER” ?
Is $MAILDIR returning “$domain/$username/Maildir” ?
Thanks,
7:45 am
@Nothing, I guess you have a different setup than we use here.
But MAILDIR is taken from the database and has a domain/user combination.
VIRTUALBASE is the root in which the virtual directories are stored per domain and per user.
12:28 pm
@Richard
Yes a have a different setup, but I try to write my own script, based 80% on your.
You have done a very good work !
Thanks for your help, I know now how to adapt this script.
7:43 pm
In the Thunderbird example above the parameter “Trust junk mail hedders set by” can be set to spampal or spamassassin.
Do these need to be downloaded and installed?
Should they be used along with DSPAM?
7:28 am
@Dennis, I had not noticed it but it looks like this feature has been removed from Thunderbird. The screenshots were made of an older version of Thunderbird. I’ll try to update these to avoid confusion.
4:31 pm
I have the latest version and it still has the options. I’m wondering if I should download and install spamassassin along with DSPAM.
6:59 pm
Use either of them, not together. They will affect each others training of ham and spam.
i haven’t researched it but perhaps there is a possibility to learn the DSpam headers in Thunderbird. But if you are tagging spam anyway why not use a rule on the inbox that moves all tagged email. What else would you use this for ?
8:11 pm
This answers my question. They are independent and with DSPAM there is no need for spamassassin. Much easier to set up on the server and not bother with each account.
Thank you