Sieve, multiple addresses, and variables

Andrew Sullivan ajs at crankycanuck.ca
Tue Apr 7 20:48:21 UTC 2015


Hi,

I have another sieve question, this time about setting variables.

I join a lot of mailing lists at ietf.org.  I thought it'd be handy to
filter these all into a common folder and then into individual
folders, without having to configure each mailing list independently.

So wrote this (this is just a part, obviously):

require ["envelope", "variables", "date", "fileinto", "mailbox" ];
     if address :is :domain "to" "ietf.org" {
             if address :matches :localpart "to" "*" {set "lopart" "${1}";}
             }
      elsif address :is :domain "cc" "ietf.org" {    
            if address :matches :localpart "cc" "*" {set "lopart" "${1}";}
         }     
      else {set "lopart" "generic-list-box";}
      fileinto :create "ietf.${lopart}-in";
      stop;
  }

Now, this works, unless someone sends a To: line like this:

To: ajs at crankycanuck.ca, listname at ietf.org

The problem in that case is that you _do_ get a match, but the bit "if
address :matches :localpart "to" "*" {set "lopart" "${1}";}" ends up
putting this in a mailbox ietf.ajs-in, when what is the mailbox
ietf.listname-in.

I thought that

  allof(if address :matches :localpart "to" "*",
  address :matches :localpart "to" "*")
  {set "lopart" "${1}";}, 

would solve this, but it doesn't seem to.  The localpart matching
catches the ajs at crankycanuck.ca address anyway, which surprised me.

Am I dim, am I not understanding something about how to do this, or is
this really impossible?

Thanks,

A

-- 
Andrew Sullivan
ajs at crankycanuck.ca


More information about the dovecot mailing list