[Dovecot] Sieve script problem (don't know if is it possible to do this)

Stephan Bosch stephan at rename-it.nl
Thu Nov 14 22:30:56 EET 2013


On 11/14/2013 7:17 PM, Yanko Hernández Álvarez wrote:
> Hello:
>
> I'm loosing my mind trying to classify my outgoing messages with
> sieve-test (2.0.9, centos 6.4). It came to the point I think it's not
> even possible with a sieve script.

Outgoing? Sieve is currently only applicable to incoming e-mail. If you
managed to do something like this, I'd be interested to find out how. :)

> I need to classify my outgoing messages in three folders:
>
> 1- To my department (@dept.example.com)
> 2- To my company (@example.com, @anyotherdept.example.com)
> (anyotherdept.example.com as in a way to say "any other domain that
> ends with 'example.com', but not 'dept.example.com'")
> 3- To the rest of the word (@any.other.domain)
>
> The problematic requirement is I need to make a copy in EVERY IMAP
> folder that applies. For instance: for an email such as
> ----
> From: myuser at dept.example.com
> To: user at dept.example.com, user at example.com, user at other.domain
> ...
> ----
> I need to make a copy to all folders: Dept (because of
> user at dept.example.com), Company (because of user at example.com) and Rest
> (because of user at other.domain).
>

This should solve the first two:

require "fileinto";
require "relational";

if address :is :domain "To" "dept.example.com" {
    fileinto "Dept";
}

if allof (
  address :value "ne" :domain "To" "dept.example.com",
  anyof (
    address :matches :domain "To" "*.example.com",
    address :is :domain "To" "example.com")) {
    fileinto "Company";
}

Unfortunately, I cannot find a way to do #3. Perhaps some extremely
convolved regular expression, but I wouldn't want to go there. Basically
one needs to test that at least one of the addresses in the message does
not match *.example.com, but I don't see how that could be achieved.

Regards,

Stephan.




More information about the dovecot mailing list