[Dovecot] Too stupid for sieve (former maildrop user)

Stephan Bosch stephan at rename-it.nl
Fri Sep 17 13:18:15 EEST 2010


  Op 17-9-2010 10:27, Dieter Knopf schreef:
> Hello,
>
> I just migrated from Postfix/Courier/Maildrop to
> Postfix/Dovecot/Deliver/Sieve and don't unterstand the right syntax
> for sieve :(
> I searched and found many small examples and many links to the RFC,
> but nothing was usefull for me (or i didn't unterstand it)
>
> I installed the latest Dovecot-Sieve (hg).
>
> Examples from my maildrop config:

I've never used maildrop before, but using its docs and some guesswork 
I'll give it a go. The mentioned folder names may depend on your 
namespace config, particularly in terms of a INBOX prefix; use whatever 
is used in IMAP. The scripts below are a little more verbose than 
necessary, as I always explicitly list the :is match type.

require "fileinto";
require "subaddress";  /* for the :domain part (last script) */

> # Filter FROM
> if($E =~ /name at domain1\.tld/)
> {
>   to "$M/.Friends.Name1/"
> }

if address :is "from" "name at domain1.tld" {
   fileinto "Friends.Name1";
}

> # Filter FROM with OR
> if($E =~ /name1 at domain1\.tld/ || $E =~ /name2 at domain2\.tld/)
> {
>   to "$M/.Friends.Name2/"
> }

if anyof (
   address :is "from" "name1 at domain1.tld",
   address :is "from" "name2 at domain2.tld") {
   fileinto "Friends.Name2";
}

Or equivalently and much shorter:

if address :is "from" ["name1 at domain1.tld","name2 at domain2.tld"] {
   fileinto "Friends.Name2";
}

> # Filter Mailinglists
> if (/^List-Id: .*<sylpheed\.sraoss\.jp>/)
> {
>   to "$M/.ML.Sylpheed/"
> }

if header :contains "list-id" "sylpheed.sraoss.jp" {
     fileinto "ML.Sylpheed";
}
> # Filter FROM AND SUBJECT
> if($E =~ /fname at domain.tld/&&  /^Subject: *foooooo/)
> {
>   to "$M/.foo/"
> }

if allof (
   address :is "from" "fname at domain.tld",
   /* Space between field name and value is trimmed implicitly */
   header :matches "subject" "foooooo*" )
{
   fileinto "foo";
}

> # Filter TO
>   if (hasaddr("name at domain.tld"))
>   {
>     to "$M/.foo/"
>   }

if address :is :comparator "i;ascii-casemap"
   ["|to"|, "|cc"|,| "resent-to"|, "|resent-cc|"]
   ["name at domain.tld"] {
   fileinto "foo";
}

> # Or something like this:
> if($E =~ /.*@facebookmail\.com/)
> {
>   if (/^Subject: .*invited you to join the group/)
>   {
>     to "$M/.Facebook.Invites.Groups/"
>   }
>   if (/^Subject: .*invited you to the event/)
>   {
>     to "$M/.Facebook.Invites.Events/"
>   }
> }

if address :is :domain "from" "facebookmail.com" {
    if header :matches "subject" "invited you to join the group*" {
       fileinto "Facebook.Invites.Groups";
    } elseif header :matches "subject" "invited you to the event*" {
       fileinto "Facebook.Invites.Events";
    }
}

> Is that possible?
Yes, given the above examples.

> Or is maildrop simple more powerful?
>
Maildrop is more powerful, particularly because it can execute arbitrary 
binaries. For security reasons, Sieve doesn't support that at all. But, 
since you are not using such functionality, your migration should be 
problem-free.

> Thank you :-)
>
PS: The above scripts were produced in an ad-hoc fashion. I haven 
bothered to do syntax checking.

Regards,

Stephan.


More information about the dovecot mailing list