How Do You Know if Bayes is not Working on Kerio MailServer?

  1. If KMS is running on Windows, get Cygwin so it is possible to run the UNIX commands in this document.

  2. Edit the spamassassin/Spamassassin.pl file:

    In the C:\Program Files\Kerio\Mailserver\spamassassin folder is a file called Spamassasin.pl.

    In the Spamassassin.pl file is the following section:

    
            $spamtest = new Mail::SpamAssassin ({
    	    rules_filename    => $rules_dir,
    	    userstate_dir     => $db_old,
    	    local_tests_only  => 1,
    	    debug             => 1,
    	    dont_copy_prefs   => 1,
    	    PREFIX            => "",
    	    DEF_RULES_DIR     => $rules_dir,
    	    LOCAL_RULES_DIR   => ""
    	})
    
    

    The default value of "debug" is 0. Change it to a 1 as shown above.

  3. Change directory to your "logs" directory. Examples using the default locations are as follows:

    Windows with cygwin:

    cd /cygdrive/c/Program\ Files/Kerio/MailServer/store/logs

    OSX:

    cd /usr/local/kerio/mailserver/store/logs

    Linux:

    cd /opt/kerio/mailserver/store/logs
  4. Check to see if the spam/not-spam buttons are working. Do this by clearing the spam and debug logs. Then, mark several messages as spam. I marked 8 messages as spam. Issue grep commands as shown to see if it is working:

    Example to see how many messages total were marked as spam:

    Administrator@blackknight /cygdrive/c/Program Files/Kerio/MailServer/store/logs
    $ grep "marked a message as spam" spam.log | wc -l
    8
    

    Example to see how many were learned:

    Administrator@blackknight /cygdrive/c/Program Files/Kerio/MailServer/store/logs
    $ grep "bayes: Learned" debug.log | wc -l
    5
    

    Example to see how many were not learned:

    Administrator@blackknight /cygdrive/c/Program Files/Kerio/MailServer/store/logs
    $ grep "not learning" debug.log | wc -l
    3
    

    In this example, 5 of the 8 messages marked as spam were learned. It seems to be working.

  5. Check to see if marking a group of messages as spam works. Do this by repeating the previous step, but select several messages with SHIFT-CLICK and mark them as spam.

  6. Check to see if the auto-learning is working. Do this by using the following process:

    1. Clear the debug log.
    2. Wait a while so incoming messages can be auto-learned.
    3. Compare the number of learning attempts with the number of spams that have been added to the bayes database during this test. If they are similar, then auto-learning is working. If very few were added to the database compared to the number of attempts, then auto-learning is not working properly.

    The following grep command will show if Bayes attempted to auto-learn any messages:

    grep "auto-learn? yes, spam" debug.log | wc -l

    The following command shows the numbers of spams in the bayes database at the beginning of the test:

    The following command shows the numbers of spams in the bayes database at the end of the test:

    grep nspam debug.log | tail -n 1

    The following is an example of a session:

    Administrator@blackknight /cygdrive/c/Program Files/Kerio/MailServer/store/logs
    $ grep nspam debug.log | head -n 1
    [07/Apr/2006 09:46:11][1052] {spam} Perl_stderr: debug: bayes corpus size: nspam
     = 4233, nham = 12952
    
    Administrator@blackknight /cygdrive/c/Program Files/Kerio/MailServer/store/logs
    $ grep nspam debug.log | tail -n 1
    [08/Apr/2006 20:28:36][1052] {spam} Perl_stderr: debug: bayes corpus size: nspam
     = 4244, nham = 12975
    
    Administrator@blackknight /cygdrive/c/Program Files/Kerio/MailServer/store/logs
    $ grep "auto-learn? yes, spam" debug.log | wc -l
    11
    
    In this example, the nspam score increased by 4244 - 4233 = 11. The number of learning attempts was also 11. Thus, it seems that auto-learning is working.