dspam Training

Training dspam from Thunderbird junk messages
Dovecot Antispam Plugin

Retrain spam message

dspam --user username --source=error --class=spam /path/to/message

Classify a message without training on it:


Dovecot Anti-Spam Plugin

The antispam plugin allows you to retrain the spam filter by simply moving emails in and out of the Spam folder.

cd /extra/src
wget -O dovecot-antispam-plugin.tar.gz http://hg.dovecot.org/dovecot-antispam-plugin/archive/tip.tar.gz
tar zxf dovecot-antispam-plugin.tar.gz
cd dovecot-antispam-plugin-5ebc6aae4d7c

Configure and build it:

ACLOCAL='aclocal -I /usr/local/share/aclocal' ./autogen.sh
./configure --prefix=/usr/local
make install

To configure it, edit /usr/local/etc/dovecot/conf.d/90-plugin.conf:


Database Maintenance

Nightly script to purge the dspam database of old information.

Performance Tuning

  • Edit /etc/my.cnf and add a query_cache:



How to authenticate into DSPAM's web interface.


mod_auth_imap is an Apache module that allows you to authenticate with an IMAP server. Since dspam is probably running on the same machine is your IMAP server, this is a viable option as well.

Apache Password File

When messages are passed through DSPAM, the recipient address dictates what user the statistics get logged to. The vpasswd for a domain can be used to generate a list of user IDs for authenticating into the DSPAM web interface.


Move spam messages

Deliver messages that have been flagged as spam by Spamassassin or dspam into special IMAP folders and remove some clutter from your Inbox.

There's a couple of ways to have spam messages filltered depending on how your Spamassassin has been configured:

  • Spamassassin has been configured to add X-Spam- headers to messages:

    if (/^X-Spam-Flag: *YES/)
      to $VHOME/Maildir/.Spam
  • Subject rewritten:
    if (/^X-Spam-Flag: *YES/)
      to $VHOME/Maildir/.Spam

Global Group

Global groups allows DSPAM to provide a "SpamAssassin type out-of-the-box filtering" for all new users until they have built their own useful dictionaries.

Create the global group for new accounts to use until they have trained enough of their own spam:

echo "defaultGroup:classification:*globaluser@example.com" > /var/dspam/group
chown simscan:simscan /var/dspam/groups

Run the following command so that dspam_clean doesn't purge your global definitions because the data is old

dspam_admin add pref globaluser@example.com trainingMode TOE


dspam WebUI

Configuring the web interface for dspam.

For the WebUI graphs, install the the GD Graphics Library:

yum install gd-devel

Then install the necessary Perl modules using CPAN:

perl -MCPAN -e shell
install GD
install GD::Graph3d
install GD::Text
install CGI


cd /extra/src/dspam-3.10.1
mkdir /var/websites/dspam /var/websites/dspam/logs
cp -R webui/cgi-bin /var/websites/dspam/
cp -R webui/htdocs /var/websites/dspam/

Edit /usr/local/apache2/conf/extra/httpd-vhosts.conf:



DSPAM is a scalable and open-source content-based spam filter designed for multi-user enterprise systems. DSPAM is an adaptive filter which means it is capable of learning and adapting to each user's email. Instead of working off of a list of "rules" to identify spam, DSPAM's probabilistic engine examines the content of each message and learns what type of content the user deems as spam (or nonspam).


  • MySQL
  • Apache webserver, compiled with:
    ./configure \
    --enable-so \
    --enable-ssl \
    --enable-rewrite \
    --enable-suexec \

    Before you compile, edit support/suexec.h and change the AP_HTTPD_USER from the default "www" to the "nobody" that our Apache install instructions use:

    #define AP_HTTPD_USER "nobody"
    #define AP_UID_MIN 99
    #define AP_GID_MIN 99



Subscribe to RSS - dspam

Recent Updates

  • 1 year 10 months ago
  • 1 year 10 months ago
  • 1 year 10 months ago
    php 8.x
  • 1 year 10 months ago
  • 1 year 10 months ago
    Drop Centos 5/6 stuff