Make kopano-spamd more flexible (configurable spam header)
-
Hi,
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.
https://stash.kopano.io/projects/KC/repos/kopanocore/browse/ECtools/spamd/kopano_spamd/init.py#70
I replaced X-Spam-Flag with X-Spam and “YES” with “Yes” ;) I hope someone could make it configurable in spamd.cfg.Marcus
-
Hi @zonk ,
if you are willing to work on this you can find contributing information at https://stash.kopano.io/projects/KC/repos/kopanocore/browse/CONTRIBUTING.md.
-
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 https://jira.kopano.io/browse/KC-1120.
-
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 junkis 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)/usr/lib/python2.7/dist-packages/kopano_spamd/__init__.py
/usr/lib/python3/dist-packages/kopano_spamd/__init__.py
change booth files from:
'header_tag': Config.string(default="x-spam-flag")
to:
'header_tag': Config.string(default="x-spam")
and
(not header or header.upper() != 'YES')):
to:
(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. https://github.com/bkram/inotify-spamlearn)You do not need to change the init.py 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 changeIf really needed the old spamd is still accessible here https://stash.kopano.io/projects/KSC/repos/kopano-spamd/browse 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:
[spam] spamcmd = rspamc learn_spam spam/ hamcmd = rspamc learn_ham ham/
bu t i hangs with python can’t find the modules:
os
subprocess
threading
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 inotify-spamlearn.py[15363]: cannot stat file spam/ Jan 16 09:08:49 smtp inotify-spamlearn.py[15363]: INFO Processing [Inotify] /var/lib/kopano/spamd/spam/0ACAA615C3524AD992F105A5E8B571EE.eml: Jan 16 09:08:49 smtp inotify-spamlearn.py[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/log.py", line 103, in log_exc try: yield File "/usr/lib/python3/dist-packages/kopano_spamd/__init__.py", line 83, in update self.learn(item, searchkey, True) File "/usr/lib/python3/dist-packages/kopano_spamd/__init__.py", 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