How to install kopano-spamd on Kopano and make it learn about SPAM

When we created our extensive Kopano guide, we never gave information on spam management. Our guide covers SpamAssassin, but as it happens Kopano needs additional software to learn about spam.

The additional software is kopano-spamd and Amavis. It’s nice and complicated, because you’ll find this useless information in the existing Kopano manual:

> Installing and configuring Amavis/Spamassassin is not part of this manual.


So what gives? Well here you’ll learn about our trials and tribulations when we tried to install Amavis and.


  1. Install kopano-spamd and start it. Set it to automatic startup.
  2. Install amavisd-new
  3. Examine the system’s groups and users.
  4. The ‘amavis’ group and the ‘kopano’ groups are relevant.
  5. The ‘kopano’ user is relevant.

From the manual:

kopano-spamd by default runs in the user context of the user kopano (as defined by run_as_user and run_as_group). To [succesfully] run sa-learn make sure that the provided user is both part of the amavis group (so [spamassasin] can process the item), as well as local_admin_user within Kopano (so kopano-spamd has access to the users mailboxes).

This complicated steps needs to be followed.

The final note on the documentation is also telling:

> All kopano-spamd does is exporting the messages as eml files. These files then still need to be fed to the preferred anti spam engine (for example Spamassasin). This feeding can for example be achieved by watching for changes in the spam/ham folders and kicking off sa-learn. See for an example of such a script.

As of January 2024 when you visit the above library you can see it’s been archived and it’s 7 years old.

The link it refers to for Kopano Core Spamd is 5 years old:

So now the question, will this work?

Linux commands:

  • apt install kopano-spamd
  • service kopano-spamd start (Also set it to automatic start)
  • apt install amavisd-new
  • getent group | grep amavis
  • getent group | grep kopano
  • getent passwd | grep kopano


When deploying this solution, start by troubleshooting the kopano-spamd daemon first. Make sure you uncomment all four lines in the logging options of spamd.cfg.

When you start the spamd and logging is enabled, you might encounter the following problem:

2024-01-25T11:06:59.642: [ERROR ] spamd - Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/kopano/", line 123, in ImportMessageChange
store_entryid = PpropFindProp(props, PR_STORE_ENTRYID).Value
AttributeError: 'NoneType' object has no attribute 'Value'

This is documented on the Kopano forum here:

The solution is to repair the `tproperties` table, however, you migth not be so lucky. First get the password out of server.cfg, then check here:

root@host:/etc/kopano# mysql -uroot -p kopano
MariaDB [kopano]> repair table tproperties;
| Table | Op | Msg_type | Msg_text |
| kopano.tproperties | repair | note | The storage engine for the table doesn't support repair |
1 row in set (0.272 sec)

Next I did this, which hung:

MariaDB [kopano]> check table tproperties;

A hung system meant mail stopped being delivered, so I had to abort that route.

Further diggiging show this:

It seems that I only get the issue when I´ve set enable_enhanced_ics = no in server.cfg

When using logging, be sure to turn the spamd.cfg log level to at least 4.

Next, you might encounter the permissions error below:

2024-01-25T11:25:34.368: [INFO ] spamd - Learning message as SPAM, entryid: 0000000080D99188BA114F05A6E8EDEC42C0D47301000000050000004EA825B5F16C43AFA62B42B29EDA3CE100000000
2024-01-25T11:25:34.589: [ERROR ] spamd - Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/kopano/", line 140, in log_exc
try: yield
File "/usr/lib/python3/dist-packages/kopano_spamd/", line 81, in update
self.learn(item, searchkey, True)
File "/usr/lib/python3/dist-packages/kopano_spamd/", line 104, in learn
os.chown(emlfilename, uid, gid)
PermissionError: [Errno 1] Operation not permitted: '/var/lib/kopano/spamd/spam/15BC6D6BA85D493EB2ACE316F85F99AA.eml'

One can see permissions are out of order, but where to fix it? Well, start by reading here:

There’s a lot to digest. As an experiment, I tried using ‘kopano’ which seemed to solve the problem of marking as SPAM, but not marking back to HAM. This time instead of “Operation not permitted” we have “Permission denied”:

2024-01-25T11:45:10.847: [INFO ] spamd - stopping spamd
2024-01-25T11:45:24.110: [INFO ] spamd - starting spamd
2024-01-25T11:45:57.941: [INFO ] spamd - Learning message as SPAM, entryid: 0000000080D99188BA114F05A6E8EDEC42C0D47301000000050000005670C0EF9B8545B9987DEA21140102AF00000000
2024-01-25T11:46:10.228: [INFO ] spamd - Learning message as SPAM, entryid: 0000000080D99188BA114F05A6E8EDEC42C0D473010000000500000064ABCD71781C49B4AC8504C10727CA8700000000
2024-01-25T11:46:15.356: [INFO ] spamd - Learning message as HAM, entryid: 0000000080D99188BA114F05A6E8EDEC42C0D47301000000050000005A5FB4AE6CED4C5E836A202F13C3753E00000000
2024-01-25T11:46:15.371: [ERROR ] spamd - Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/kopano/", line 140, in log_exc
try: yield
File "/usr/lib/python3/dist-packages/kopano_spamd/", line 92, in update
self.learn(item, searchkey, False)
File "/usr/lib/python3/dist-packages/kopano_spamd/", line 99, in learn
with closing(open(emlfilename, "wb")) as fh:
PermissionError: [Errno 13] Permission denied: '/var/lib/kopano/spamd/ham/15BC6D6BA85D493EB2ACE316F85F99AA.eml'

Browing the directories we have this:

root@host:/var/lib/kopano/spamd# ls -lah
total 24K
drwxr-xr-x 4 kopano kopano 4.0K Jan 25 11:22 .
drwxr-xr-x 9 kopano kopano 4.0K Jan 24 12:02 ..
drwxr-xr-x 2 root root 4.0K Jan 24 12:03 ham
drwxr-xr-x 2 kopano kopano 4.0K Jan 25 12:01 spam
-rw-rw-rw- 1 kopano kopano 8.0K Jan 25 12:01 spam.db

Amazing! Changing ham to kopano:kopano actually made it work 🙂



Share this article

Leave a Reply

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

Scroll to Top