sieve and multiple ACTIVE scripts

1.7k Views Asked by At

Is there a reason the email filter sieve can only activate one single script?

 > list
 "mailinglists.sieve"
 "spam.sieve" ACTIVE
 > activate mailinglists.sieve
 > list
 "mailinglists.sieve" ACTIVE
 "spam.sieve"
 > 

I can't see the logic here ... I am doing something wrong?

2

There are 2 best solutions below

0
On

Most email sieve servers want one "main" sieve script to run. Since the order of running sieve commands matters, you'd need to have some method to specify what order the files should execute in.

So, the standard way to handle this is with the "include" extension, defined in RFC 6609. You can have one main sieve script, and include your other sieve scripts as needed. The server administrator can also define "global" scripts that can be included by any user, such as with Dovecot Pigeonhole's sieve_global_dir configuration line.

Example usage from the RFC:

require ["include"];

include :personal "always_allow";
include :global "spam_tests";
include :personal "spam_tests";
include :personal "mailing_lists";
0
On

To add a bit to the answer, if you're looking to configure multiple sequential sieve scripts for Dovecot then you may use sieve_beforeX= and sieve_afterX= parameters as described here: https://doc.dovecot.org/configuration_manual/sieve/configuration/#executing-multiple-scripts-sequentially

For example:

sieve_before = /usr/local/lib/dovecot/sieve/spam.sieve
sieve_before2 = /usr/local/lib/dovecot/sieve/ham.sieve
sieve_before3 = /usr/local/lib/dovecot/sieve/check.sieve

sieve_after = /usr/local/lib/dovecot/sieve/move.sieve
sieve_after2 = /usr/local/lib/dovecot/sieve/flag.sieve