Kerio Connect: Enabling DCC on Spam Assassin

KMS (Kerio Mail Server) comes with the Spamassassin spam protection. Although not officially supported by Kerio, you can change spamassassin by modifying the spamassassin rules and config files. On Windows, all the important files are in

C:\Program Files\Kerio\MailServer\plugins\spamassassin\rules

Before you change anything, you should definitely backup all files in this directory!

The .cf files contain the rules and the scores. They are plain text and you can change them, but you have to know what you are doing. You can also add new ones, for example 80_MyAntiSpamRules.cf. You need to restart the KMS Mail services to make the changes effective.

Spamassassin comes with three modules that are based on check-sums of mails: Pyzor, Razor2 and DCC. But they are not enabled in KMS. Unfortunately, it is not just a matter of enabling them as the executables for them are missing.

So I spent about 5 hours to figure out how I could get DCC to work (I chose DCC because I don't need Python on my system for it to work).

What is DCC?

The DCC or Distributed Checksum Clearinghouse is a system of servers collecting and counting checksums of millions of mail messages. The counts can be used by SpamAssassin to detect and reject or filter spam. See http://www.rhyolite.com/anti-spam/dcc/ for details.

I had to do the following steps to get in to work on Windows (similar steps on Unix and Mac, I guess):

  1. Download SpamAssassin for Win32 command-line tools from http://sawin32.sourceforge.net/ and unzip it to c:\sa
  2. Make sure that you c:\sa\dccproc.exe is in place. This is the main executable for DCC.
  3. Open a cmd prompt and type

    c:
    cd "Documents and Settings\Default User"
    md .spamassassin

  4. Important: On a 64-bit Windows 2008 R2 server, the path is: C:\Windows\SysWOW64\config\systemprofile\.spamassassin
  5. Copy the "map" file from C:\sa\etc\dcc to C:\Documents and Settings\Default User\.spamassassin   This file contains the servers that can be contacted for Spam checksums.
  6. Locate and open C:\Program Files\Kerio\MailServer\plugins\spamassassin\rules\local.cf
  7. Add the following lines:

    # Use DCC
    dcc_home c:\sa\etc\dcc
    dcc_path c:\sa\dccproc.exe
    add_header all DCC _DCCB_: _DCCR_
    use_dcc 1

  8. Remove the following line

    score DCC_CHECK 0

  9. In the same directory, open the v310.pre file and uncomment the following line

    loadplugin Mail::SpamAssassin::Plugin::DCC

  10. Restart KMS
  11. Also note that DCC requires that you open your firewall for DCC reply packets on UDP port 6277. Here's sample firewall rules required:
    allow udp local gt 1023 to remote 6277
    allow udp remote 6277 to local gt 1023

From now on you should see an entry in the headers of your incoming mails (if DCC detects it as spam):

DCC_CHECK: 1.37

The score depends on what you have defined in 50_scores.cf

Update: This has also been tested on Kerio Connect 7.3 and it is working.

Update 2: According to John's post below, to make DCC work in Kerio Connect 7.4, you have to add some lines to Util.pm in addition to the steps above. For details, see John's post below. Thanks John for that!

Update 3: This also works in Kerio Connect 8.0.

7 thoughts on “Kerio Connect: Enabling DCC on Spam Assassin”

  1. Hi, I did the tests!
    Instead of removing the line:
    score DCC_CHECK 0
    Change to:
    score DCC_CHECK 3.37 <-- this is my score!

    :-) cabelo

  2. According to the release notes, the Spam Assasin version hasn't changed, so there is a chance that it wiil work. I didn't have time to test it yet, but i will update the post, once I have tested it.

  3. Kerio Connect 7.4 is running a new version of SA and site\lib\Mail\SpamAssassin\Util.pm will through errors when enabling DCC because of missing POSIX functions. I redefined them by editing the file and adding the following code after the "use constant RUNNING_ON_WINDOWS..." line:

    # These are not implemented on windows
    if (RUNNING_ON_WINDOWS) {
    *WIFEXITED = sub { not $_[0] & 0xff };
    *WEXITSTATUS = sub { $_[0] >> 8 };
    *WIFSIGNALED = sub { $_[0] & 127 };
    *WTERMSIG = sub { $_[0] & 127 };
    }

    1. Hey, I found this problem on KC 7.4 as well and didn't know how to solve it. Thanks for this solution, will try it on my Kerio installations. Thanks a lot!

    2. I can confirm that John's solution is working on Kerio Connect 7.4. Thanks a lot for that, I have updated the article accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *