1

How can I set up a per-domain filter in sieve/dovecot?

In documentation I can see per-user setting: sieve = ~/.dovecot.sieve, and right now I'm using global filter: sieve_before = /etc/dovecot/sieve/global . However, I'd like to be able to set up filters per domain basis.

James S.
  • 67
  • 2
  • 11

1 Answers1

3

In short - you can't.

Dovecot allow only global and per-user sieves.

before/default/after sieves are global and applied to each message. If you are sure that you want to process all messages in the same way you have to set up the sieve_before filter, not the default. But there is a not well explained trap here.

sieve_before may consist of number of rules. First matched rule will be applied and sieve processing will be stopped. If you want then to pass message to the user sieve for additional filtering you have to add the verb keep to the end of specific rule.

require "fileinto";
# rule:[some_domain]
if header :contains "From" "some.domain.tld"
{
  fileinto "some_domain_tld";
  keep;
}
elseif . . . . . 
{
    . . . . .
   keep;
}
else
{
   keep;
}

If keep verb is omitted then sieve engine will treat that as implicit verb stop and message wouldn't be passed to the user's sieve.

Kondybas
  • 6,964
  • 2
  • 20
  • 24