kopano-spamd won't learn any spam

  • Hello Guys,

    I’ve setup kopano-spamd on Ubuntu 16.04. I had it already working properly but I think after moving my installation to another disk with rsync my spam-db was lost or something else went wrong.

    If I drag a spam mail to the spam folder, I always get:

    2017-03-21 15:44:06,079 - spamd - INFO - [gerrit] sa-learn: Learned tokens from                                                                                                                                                              0 message(s) (1 message(s) examined)

    in the spamd.log

    spamassasin debug log shows:

    For debugging I’ve set the permissions of /home/gerrit/.spamassasin to 777 and still it won’t learn anything. The example spam-mail even shows a score above 5, it was an old mail I found in my inbox. I don’t see any reason why it doesn’t work anymore.

    Any help is appreciated :)

  • Ok, I’ve found the reason. The script creates a folder in /tmp on start called tmp(something) with rwx permissions only for the user kopano , but sa-learn is called with the user amavis. After running the script from commandline I got the following output:

     suconfig: path "/tmp/tmpgQePIs/.spamassassin" is inaccessible: Permission denied
    config: path "/tmp/tmpgQePIs/.spamassassin/user_prefs" is inaccessible: Permission denied
    do config: path "/tmp/tmpgQePIs/.spamassassin" is inaccessible: Permission denied
    config: path "/tmp/tmpgQePIs/.spamassassin" is inaccessible: Permission denied
    bayes: expire_old_tokens: locker: safe_lock: cannot create lockfile /tmp/tmpgQePIs/.spamassassin/bayes.mutex: Permission denied
    plugin: eval failed: bayes: (in learn) locker: safe_lock: cannot create lockfile /tmp/tmpgQePIs/.spamassassin/bayes.mutex: Permission denied
    ERROR: the Bayes learn function returned an error, please re-run with -D for more information at /usr/bin/sa-learn line 501.

    If I do a chmod 777 on that folder everything works fine. Does anybody have an idea how to change that permissions the script sets? If anybody is wondering, I’m talking about this script https://kb.kopano.io/display/WIKI/Kopano-spamd


  • @Gerrit507

    I followed this
    as described here

    and that works for me



  • @externa1 I have this line, too. The issue is still that the user kopano creates a folder which the user amavis can not access. Do you use mysql or files for spamassassin? This user also reports that it only works with mysql. I think it could be the same issue.


  • Sorry to bump an old thread, but I didn’t see a solution to this anywhere, and wanted to add mine in case anyone else comes across this problem. When using amavisd-new, you can force sa-learn to use the correct Bayes Database by specifying:

    bayes_path /var/lib/amavis/.spamassassin/bayes

    in /etc/mail/spamassassin/local.cf

  • Hai,

    I use this setup on debian stretch with spamassassin and this works great.
    Small side note, i use Spamassassin and Bayes in MariaDB (mysql).
    setup found here:

    my steps:
    get the source of kopano-spamd and put them in /usr/local/bin
    imo, should be in sbin, but lets ignore that for now.

    create the systemd file : /etc/systemd/system/kopano-spamd.service

    Description=Kopano Core Spamd (Community)
    After=kopano-server.service kopano-gateway.service mariadb.service mysql.service
    Wants=kopano-server.service kopano-gateway.service mariadb.service mysql.service
    Environment=LC_ALL=C LANG=C
    ExecStart=/usr/local/bin/kopano-spamd.py -F
    ExecReload=/bin/kill -HUP $MAINPID

    In /usr/local/bin/kopano-spamd.py.
    change the first line to :
    #!/usr/bin/env python2

    change the “learncmd” in the CONFIG= part.
    I changed the user/group to kopano and spamassassin to debian-spamd.

    CONFIG = {
        'run_as_user': Config.string(default="kopano"),
        'run_as_group': Config.string(default="kopano"),
        'learncmd': Config.string(default="/usr/bin/sudo -u debian-spamd /usr/bin/sa-learn --spam")

    I used spamassassing with clamav so change that to amavis.
    Dont forget to allow the amavis user in your spamassassin folders,
    This is not needed when you run in SQL setup with spamassassin/amavis.

    i did also notice a few python dependecies that i was missing.
    that one or more of these fixed my issue.
    python-configobj python-linecache2 python-traceback2 python-tracer


Log in to reply