I'm experiencing an issue with messages that are being flagged as spam. For some accounts mesagges are being correctly identified as SPAM (name is being changed to ***SPAM***) but for some reason not all of them are being automatically moved from INBOX to SPAM folder. For other accounts (all under the same domain) it works fine. Could you please let me know how this can be fixed.

Re: Spam not being transferred to spam folder

It's hard to say without related log.Could you please show us the sieve script you used to move spam to SPAM folder? Any related log in /var/log/sieve.log (i believe you have to turn on debug mode in Dovecot to get detailed debug log)?

From sieve log it's quite clear that it places the same message that was sent to two different accounts into different folders. The one that is put inside inbox is being identified as spam, according to the header, but still goes to inbox: