How to Install and configure spam-filter DSpam (dspam, dspam-web, dovecot-antispam) in CentOS/RHEL 7

Installing DSpam

First install the required packages:

In CentOS 6 user dspam was created with UID that is less than 500 and there was a problem with the launch of the Web part, so Apache DSpam had to change UID. Now this part is not relevant:

We will create for DSpam database and a special user in MySQL:

Now let’s create the MySQL database required for the tables:

Let’s agree that here and below instead of %DSpamDB% and %DSpamUser% and %DSpamPassWord% to enter the database name, user name, and password. No percent signs!

Setting up DSpam

You can now run the DSpam:

Configuring postfix

Configure SELinux for DSpam and Postfix

When SELinux is appropriately configured to link postfix and DSpam – postfix can be restarted:

Configuration of fetchmail

Configure fetchmail in order to have it adopted by the post office has been using DSpam:
Variant 1 (easier)

Variant 2 (correct):
In the fetchmail configuration, in PostfixAdmin need to write the next mda:

just so, with the quotation marks. Keep in mind, should be corrected so PostfixAdmin as described in this article, otherwise it would be wrong to record values PostfixAdmin MDA in a MySQL database.

Configuring Apache and DSpam-web

Configure SELinux for DSpam-web and Apache

Restart Apache:

You can now open the browser the link to access the DSpam-web.

Configuring Dovecot

For Dovecot mail with spam in the Spam folder, put the need to do the following:

Thus all messages where the subject (or the author) is the word VIAGRA will be automatically deleted. And those letters DSpam has marked as Spam will be marked as read and go to the folder Spam. Keep in mind, Dovecot must be configured as described in this article.

But, as you know, in some cases, spam emails are not detected as Spam, and some letters, in contrast, are marked as spam by mistake. In such cases, it is necessary to say that there is DSpam letter, for example, don’t spam, and here it is, on the contrary the spam. Need it for self-study DSpam.
Mark erroneous emails as spam/non-spam in web-interface DSpam, but it is a complicated option, we will set up easier.

dovecot-antispam plugin installation

For Dovecot has a special plugin, which will monitor the movement of messages in the mailbox and if necessary pass them on training DSpam. For example, if you pull out from the Spam folder (except for the cases when these letters put in a basket), this letter is DSpam with words is not a spam. And if on the contrary, put in the Spam folder, the email is passed to the DSpam with words is spam!

Plugin that provides the desired functionality in CentOS repositories is absend, so gather it and install from source. To do this, do the following:

In CentOS 6 package dovecot-devel is in EPEL repository, so there was no need for it to download from In CentOS 7 at the time of this writing, this package in EPEL repository has not been, so if the command yum -y install dovecot-devel error – download the package and install manually. And if the package is installed from the repository – download and install it manually will not need to.

If, at the time the command make install, we will see the following errors:

you will need to do the following:

If there is no error messages – then everything is OK.

Now write the compiled and installed the plugin in settings of dovecot:

Configure SELinux for dovecot-antispam plugin

After configuring the plugin, restart the dovecot:

We can try to put the letter in the Spam folder and view in the Web interface if the status has changed, the DSpam this letter in the “history” tab.
You can also view errors in SELinux:

If there are no errors, and the status message in the Web interface changes is DSpam we have configured everything correctly.

Update from 2016-01-18

During the next update CentOS, refused to update dovecot packages:

yum we offer run yum check, Ok, let’s try it:

Expected did not help. Okay, remove the package that prevents us from original, upgrade packages, and then again install dovecot-devel.

Upgraded. 🙂


  1. Bezaleel Ramos
    26.09.2015 - 23:13


    Nice tutorial.

    I’m with problem in start dspam:

    Sep 27 01:38:20 dspam01 dspam: /usr/bin/dspam: symbol lookup error: /usr/bin/dspam: undefined symbol: external_lookup
    Sep 27 01:38:20 dspam01 systemd: dspam.service: control process exited, code=exited status=127
    Sep 27 01:38:20 dspam01 systemd: Failed to start A highly accurate statistical spam filter that uses minimal resources.
    Sep 27 01:38:20 dspam01 systemd: Unit dspam.service entered failed state.
    Sep 27 01:38:37 dspam01 auditd[579]: Audit daemon rotating log files

Leave a Reply