[Dovecot] Quick question on sieve

Stephan Bosch stephan at rename-it.nl
Wed Nov 20 00:36:23 EET 2013


On 11/19/2013 11:00 PM, LuKreme wrote:
> I have a procmail recipe that does the majority of my heavy lifting for my mailing lists. It's pretty straightforward, but as I understand it, this isn't something sieve can do:
>
> # [  ] contains a space and a tab
> :0
> * 9876543210^0 ^(List-Id:.*<|X-Mailing-List:[  ]*)\/[-A-z0-9_+]+
> * 9876543210^0 ^(List-Post:[  ]*(<mailto:)?|List-Owner:[  ]*(<mailto:)?owner-)\/[-A-Z0-9_+]+
> * 9876543210^0 ^(Sender:[  ]*owner-|X-BeenThere:[  ]*|Delivered-To:[  ]*mailing list )\/[-A-Za-z0-9_+]+
> * 9876543210^0 ^Sender:.* List"? <(mailto:)?\/[-A-Z0-9_+]+
> { LISTNAME=$MATCH }
>
> Basically, it checks the headers for any one of the headers
>
> List-ID:
> List-Post:
> List-Owner:
> Sender: owner-
> X-BeenThere:
> Delivered-To:
> Sender:.*List
>
> and parses out the name of the list, writing it to the LISTNAME variable 
>
> For the vast majority of mailing lists the message is then written to
>
> .$LISTNAME/
>
> This means that, by default, a new mailing list is automatically sorted to its own mailbox without my doing anything at all.
>
> Is this something hat Sieve can do? Does it have variable assignment?

Yes and yes. I'd normally translate the above Procmail recipe for you,
but it is a bit hard to read because my Procmailese is a bit rusty
regarding regular expressions. So I'll just work with your question. A
very simple example looks as follows:

require "variables";
require "fileinto";

if header :matches "list-id" "*" {
    set "listname" "${1}";
}

fileinto "$listname";

The mailbox dot prefix is implicit (assuming it is a maildir). To fully
translate your recipe, you'll probably need the regex extension
(http://tools.ietf.org/html/draft-murchison-sieve-regex-08) as well. The
(match) variables are documented in RFC 5229
(http://tools.ietf.org/html/rfc5229).

Regards,

Stephan.




More information about the dovecot mailing list