Make kopano-spamd more flexible (configurable spam header)


it would be nice, if I could configure kopano-spamd more flexible to use it with other spamfilters than spamassasin. I currently use rspamd which is using “X-Spam: Yes” instead of “X-Spam-Flag: YES” in mail headers. I found the check in the code and edited it manually for my needs.
I replaced X-Spam-Flag with X-Spam and “YES” with “Yes” ;) I hope someone could make it configurable in spamd.cfg.


Hi @zonk ,

if you are willing to work on this you can find contributing information at

i will try it. sadly i’m not a dev.

Just ran into this same issue. Sent a patch contribution which implements this flexibilty.

Hi @tph2018 ,

thanks for your patch. I’ve asked one of our developers to take a look at you patch files and then open a pr internally.

Ticket for status updates is

Hi there

i have a question about this.
I installed rspamd too and it works but i think kopano-spamd not comunicating with rspamd. Especially move to junk

is this the only thing that must be do for working ?

change the setting in python for SPAM Flag
(note! if do a update you lost it)


change booth files from:
'header_tag': Config.string(default="x-spam-flag")
'header_tag': Config.string(default="x-spam")

(not header or header.upper() != 'YES')):
(not header or header.upper() != 'Yes')):

@noise Actually kopano-spamd is not communicating to whatever spam daemon you are using.

Kopano-spamd just create eml files of the items that are put in the junk-folder (default location : /var/lib/kopano/spamd/spam)
You need to create something for you spam daemon (e.g.

You do not need to change the file as header_tag is an config option at the moment just add/change it in /etc/kopano/spamd.cfg
The last change will never work as the header is all in uppercase so it will never match your change

If really needed the old spamd is still accessible here but this was just created as an prove of concept and is not supported.
But the benefit can be that you the command added on learncmd in the cfg is just used to learn the spam to any spam daemon you are using without creating a separate script

@robing said in Make kopano-spamd more flexible (configurable spam header):

learncmd in the cfg

do you mean spamcmd

i try it and set:

spamcmd = rspamc learn_spam spam/
hamcmd = rspamc learn_ham ham/

bu t i hangs with python can’t find the modules:

the other modules i install with:
apt install python-pip
pip install logging configparser inotify

ModuleNotFoundError: No module named 'inotify'

but notify is installed

@noise i had the same issue as you that it could not find the module.
The reason as well the solution are described here: define-ham-and-spam-for-spamassassin

@BMWfan thanks

I installed now on my ubuntu 18.04:

apt-get install python3-setuptools
apt install python3-pip
pip3 install inotify

inotify-spamlearn.service is running now but i got more errors:

==> /var/log/syslog <==
Jan 16 09:08:49 smtp[15363]: cannot stat file spam/
Jan 16 09:08:49 smtp[15363]: INFO Processing [Inotify] /var/lib/kopano/spamd/spam/0ACAA615C3524AD992F105A5E8B571EE.eml:
Jan 16 09:08:49 smtp[15363]: INFO Removing file: /var/lib/kopano/spamd/spam/0ACAA615C3524AD992F105A5E8B571EE.eml

==> /var/log/kopano/spamd.log <==
2019-01-16 09:08:49,381 - spamd - ERROR - Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/kopano/", line 103, in log_exc
    try: yield
  File "/usr/lib/python3/dist-packages/kopano_spamd/", line 83, in update
    self.learn(item, searchkey, True)
  File "/usr/lib/python3/dist-packages/kopano_spamd/", line 105, in learn
    gid = grp.getgrnam(self.sagroup).gr_gid
KeyError: 'getgrnam(): name not found: amavis'

is amavis needed !? and comes these errors because it is not installed ?

@noise i would like to say it depends on your infrastructure. Is amavis in use in yours?
Which sa_group is defined in your /etc/kopano/spamd.cfg?

@BMWfan no amavis is not in use and sa_group is uncommented in spamd.cfg. only rspamd is installed