Spamassassin, Dovecot and Postfix: Move spam to folder

Solution 1:

In my case I was missing include conf.d/*.conf line in dovecot.conf and dovecot did not read configuration from these files including 90-plugins.conf.

But I did not include that line because all my config is already in dovecot.conf and conf.d/*.conf files will override it with default settings so I simply included these lines in dovecot.conf:

plugin {
    sieve = /etc/dovecot/sieve/default.sieve
}

protocol lda {
    mail_plugins = $mail_plugins sieve
}

All your other configuration is fine and should work (it seems that you get them from this answer).

Solution 2:

To manage filter rule you can use sieve on dovecot. You can put it as global sieve or per user sieve.

For global sieve use configuration in /etc/dovecot/dovecot.conf :

sieve_global_path = /home/vmail/sieve/dovecot.sieve

For sieve per user use configuration :

sieve = /%Lh/sieve/dovecot.sieve

which %Lh===dovecot will change it to user mailbox dir

This is example for sieve files content:

if header :contains "*****SPAM*****" "YES"
{
    fileinto "Junk";
    stop;
}