I need top classify my incomming emails using this three rules:
- if the email was send to any @somedomain.tld, then copy that email to "somedomain_tld"
- if the email was send to any other @*.tld , then copy that email to "others_tlds". (any other = "not somedomain.tld")
- The rest of emails, copy to a third folder "rest".
I'm using dovecot sieve rules to do this.
There is an additional condition: the three rules above must be applied to every "To:" address in the email... So in the most complex case, the email should be copied in the three folders
for example: the following email should be copied to the three folders:
From: user@someunrelateddomain.anytld
To: myaddress@mydomain.mytld, user@otherdomain.tld, user@somedomain.tld
Subject: Test Email
This is a test email
- Because of "user@somedomain.tld" this email should be copied to "somedomain_tld"
- Because of "user@otherdomain.tld" this email should be copied to "others_tlds"
- Because of "myaddress@mydomain.mytld" this email should be copied to "rest"
The require and the first rule is easy:
require ["fileinto","copy"];
if address :is :domain "to" "somedomain.tld" { fileinto :copy "somedomain_tld"; }
but the second don't know how to do it:
if address :matches :domain "to" "*.tld" { fileinto :copy "others_tlds"; }
will match somedomain.tld also, which is not what is intended... (if I have an email with "To: user@somedomain.tld" it will be copied to somedomain_tld (OK) and others_tlds (BUG))
For #3 I don't have a clue.
I was also thinking of regexes, but I don know how to express "every domain except this" in a sieve regex (or any other regex style)
Does anyone knows how to bends dovecot's sieve to do 1,2,3?