invoke filtering manually in dovecot+sieve

I've configured dovecot with a sieve filtering (also I've configured roundcube, but this does not matter I think).

It's working fine, I've set up some filters. But now I've got a huge unfiltered INBOX folder which I don't want to filter manually.

Is there any way to say: "Hey, sieve! Scan specified folder for specified user and invoke some filters on it!" ?

Sieve as plugin enabled for two protocols: lda and lmtp:

protocol lda {
  mail_plugins = $mail_plugins sieve
}

protocol lmtp {
  postmaster_address = [email protected]
  mail_plugins = sieve
}

To execute your filters on your existent mailbox you can manually run sieve-filter from the command line.

To (dry) run the sieve-script example.sieve as user test on the mailbox INBOX use the following command:

sieve-filter -v -C -u test /path/to/sieve/example.sieve 'INBOX'

Once you like the actions sieve would perform you can execute the script with adding -e for execute and -W to give sieve write access.

For more information look at the official man page: http://pigeonhole.dovecot.org/doc/man1/sieve-filter.1.html


It's easy :(

sudo su user-which-owns-mails
sieve-filter -e -W -u [email protected] /path/to/sieve/script.sieve INBOX