Bug - Incoming spam emails is not sorted into junk folder

Incoming spam emails is not sorted into junk folder.
Why?

root@kopano:[~]: kopano-server -V
kopano-server 8.7.80
root@kopano:[~]: cat /etc/kopano/dagent.cfg | egrep -v "(^#.*|^$)"
log_level	=	5
log_raw_message = yes
log_raw_message_path = /tmp/raw_messages
spam_header_name = X-Spam
spam_header_value = Yes
root@kopano:[~]: grep -i 'spam' /tmp/raw_messages/LMTP_20181204122623_641be4e6.eml
X-Rspamd-Queue-Id: D428A44FF9
X-Spamd-Result: default: False [11.15 / 15.00];
X-Rspamd-Server: smtp
X-Spam: Yes
Dec 04 12:26:23 kopano kopano-dagent[4694]: Accepted connection from [::ffff:14.153.254.211]:49396
Dec 04 12:26:23 kopano kopano-dagent[4696]: Starting worker for LMTP request pid 4696
Dec 04 12:26:23 kopano kopano-dagent[4696]: Resolved recipient arne@xxxxxx.se as user arne
Dec 04 12:26:23 kopano kopano-dagent[4696]: * Loading plugins started
Dec 04 12:26:23 kopano kopano-dagent[4696]: ** Checking plugins in /var/lib/kopano/dagent/plugins
Dec 04 12:26:23 kopano kopano-dagent[4696]: * Loading plugins done
Dec 04 12:26:23 kopano kopano-dagent[4696]: Mail will be delivered in Inbox
Dec 04 12:26:23 kopano kopano-dagent[4696]: * PostConverting processing started
Dec 04 12:26:23 kopano kopano-dagent[4696]: * PostConverting processing done
Dec 04 12:26:23 kopano kopano-dagent[4696]: * PreDelivery processing started
Dec 04 12:26:23 kopano kopano-dagent[4696]: * PreDelivery processing done
Dec 04 12:26:23 kopano kopano-dagent[4696]: * PreRuleProcess processing started
Dec 04 12:26:23 kopano kopano-dagent[4696]: * PreRuleProcess processing done
Dec 04 12:26:23 kopano kopano-dagent[4696]: * PostDelivery processing started
Dec 04 12:26:23 kopano kopano-dagent[4696]: * PostDelivery processing done
Dec 04 12:26:23 kopano kopano-dagent[4696]: * SendNewMailNotify processing started
Dec 04 12:26:23 kopano kopano-dagent[4696]: * SendNewMailNotify processing done
Dec 04 12:26:23 kopano kopano-dagent[4696]: Delivered message to "arne", Subject: "See attachment for more information", Message-Id: <kcis.FE63CF182D8C44568A92F40DDA1A87DC@kopano.xxxxx.io>, size 3662
Dec 04 12:26:23 kopano kopano-dagent[4696]: Finished processing message
Dec 04 12:26:23 kopano kopano-dagent[4696]: Raw message saved to "/tmp/raw_messages/LMTP_20181204122623_641be4e6.eml"
Dec 04 12:26:23 kopano kopano-dagent[4696]: LMTP thread exiting

Postfix has this configuration on a separate virtual host:

root@smtp:[~]: grep -i 'kopano' /etc/postfix/main.cf
virtual_transport = lmtp:kopano.lxd:2003
-1

hi @Blinkiz
this is my config:
cat /etc/kopano/dagent.cfg | egrep -v “(^#.*|^$)”
server_socket = file:///var/run/kopano/server.sock
log_method = file
log_file = /var/log/kopano/dagent.log
log_timestamp = 1
log_raw_message = no
log_raw_message_path = /tmp
log_buffer_size = 4096
tmp_path = /tmp
server_bind = 127.0.0.1
lmtp_port = 2003
lmtp_max_threads = 20
pid_file = /var/run/kopano/dagent.pid
spam_header_name = X-Spam-Status
spam_header_value = Yes,
archive_on_delivery = no
plugin_enabled = yes
plugin_manager_path = /usr/share/kopano-dagent/python
plugin_path = /var/lib/kopano/dagent/plugins
set_rule_headers = yes
no_double_forward = no
default_charset = iso-8859-15

check if spam_header_name = X-Spam-Status works

@AnotherAndy Am sorry if I was not clear enough. My bad. As you can see in my first post, “X-Spam-Status” does not exist in the incoming email but “X-Spam” does.

Dec 04 12:26:23 kopano kopano-dagent[4696]: Mail will be delivered in Inbox

Unless you define some rules, or have some other magical extra component that does it for you, it won’t be moved to Junk.

@jengelh Hello there. Thanks for replying.
In the config file /etc/kopano/dagent.cfg it says

# The following e-mail header will mark the mail as spam, so the mail
# is placed in the Junk Mail folder, and not the Inbox.
# The name is case insensitive.
# set to empty to not use this detection scheme.
spam_header_name = X-Spam

I read it as the incoming email will be placed in the Junk Mail folder, and not the inbox. Is that not correct?

-1

Hi @Blinkiz ,
that’s what I tried to say, use
“spam_header_name = X-Spam-Status” - without “” in your dagent.cfg
We had a similar topic here:
https://forum.kopano.io/topic/125/spam-is-not-sorted-into-junk-folder/4

@AnotherAndy
Okay, I changed back to spam_header_name = X-Spam-Status and it still does not work. Again, I do not have a X-Spam-Status header in my incoming emails. I have X-Spam instead.

-1

I’m sorry I thought you were also using spamassassin.
maybe @jengelh can tell the magic tricks to do

I found why it does not work for me. Look at the incoming message I wrote in my first post.

root@kopano:[~]: grep -i 'spam' /tmp/raw_messages/LMTP_20181204122623_641be4e6.eml
X-Rspamd-Queue-Id: D428A44FF9
X-Spamd-Result: default: False [11.15 / 15.00];
X-Rspamd-Server: smtp
X-Spam: Yes

I then specify to look for X-Spam in my configuration.

root@kopano:[~]: cat /etc/kopano/dagent.cfg | egrep -v "(^#.*|^$)"
log_level	=	5
log_raw_message = yes
log_raw_message_path = /tmp/raw_messages
spam_header_name = X-Spam
spam_header_value = Yes

Looking at the source code at https://github.com/Kopano-dev/kopano-core/blob/master/spooler/DAgent.cpp i can see that only the first match is returned. In my Message I first have “X-Spamd-Result” which will be the one Kopano is checking against and not “X-Spam” header.

This is a bug in the Kopano code.