Incoming emails is always checked by external spam protection software before it arrives into mailboxes. The external spam protection is adding spam markers into the header of the email if it thinks incoming email is a spam.
Sometimes the external spam protection is marking emails wrong as spam and then it’s up to the user to teach the external spam protection software that this email is not spam. This is the way to learn Artificial Intelligence, we need to teach the spam protection software how to behave. AI needs to learn by it’s mistakes just like humans.

Incoming emails
Incoming emails which has the spam marker in email header is moved to Junk folder by kopano-dagent.

root@kopano:[/etc/kopano]: grep -i '^spam' /etc/kopano/dagent.cfg 
spam_header_name = X-Spam
spam_header_value = Yes

In logfile for kopano-dagent, lines like this can be found:

root@kopano:[/etc/kopano]: journalctl -u kopano-dagent | grep --max-count=1 'Spam'
Dec 06 09:37:44 kopano kopano-dagent[12458]: Spam marker found in e-mail, delivering to junk-mail folder

Moving message away from Junk folder
If the message delivered into the Junk folder is not spam the external spam protection software needs to know about it.
kopano-spamd is perfect for this but has one tiny flaw.

root@kopano:[/etc/kopano]: grep '^header_tag' /etc/kopano/spamd.cfg 
header_tag = X-Spam

kopano-spamd is told not to process any emails which has the header “X-Spam”. That is good for incoming emails so the external spam protection software do not get same email twice learned as spam. But problem is that it ignores if I move a email from Junk folder to inbox which has spam marker in it’s header.

Question
How can I teach external spam protection software if one email is not spam (ham) but has spam marker in it’s header?