Have dovecot+sieve. It's most often recommended that users train spamassassin/rspamd in the following way:
A Spam folder is created in each mailbox (Junk type)
Further, through the imap_sieve plugin, we look, if the letters are moved to this folder, then we consider them spam and call the script (in this case, spam.sh)
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "spam.sh" [ "${username}-spam" ];
If these are normal emails, then when moving FROM the spam folder to any other, we consider them ham and call the ham.sh script
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" {
set "mailbox" "${1}";
}
if string "${mailbox}" "Trash" {
stop;
}
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "ham.sh" [ "${username}-ham" ];
So the question is, how does this normally work? Emails after "Antispam" that scored average points are usually placed in the inbox marked SPAM. If it's really spam, we move them to the Spam folder, everything is ok here.
But what if SPAM mark received a normal email? In order for the ham script to work, you need to place them first in the spam folder and then move them from there to another, and you get two script calls for one email (both spam and ham), makes no sense for me.