> 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";
> }

It doesn't work...
----------------------------
$ cat > Test.eml
From: Yanko Hdez Alvarez <[email protected]>
To: Jorge Naranjo <[email protected]>, The Boss
<[email protected]>, Yanko Hernandez Alvarez <[email protected]>
Subject: This is a Test

This is a test
^d
$  cat > Test.sieve
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";
}
^d
$ sieve-test -t- -Tlevel=matching Test.sieve Test.eml

      ## Started executing script 'Test'
   4: address test
   4:   starting `:is' match with `i;ascii-casemap' comparator:
   4:   extracting `To' headers from message
   4:   parsing address header value `Jorge Naranjo
<[email protected]>, The Boss <[email protected]>, Yank...'
   4:   extracting `domain' part from address `[email protected]'
   4:   matching value `dept.example.com'
   4:     with key `dept.example.com' => 1
   4:   finishing match with result: matched
   4: jump if result is false
   4:   not jumping
   5: fileinto action
   5:   store message in mailbox `Dept'
   8: address test
   8:   starting `:value-ne' match with `i;ascii-casemap' comparator:
   8:   extracting `To' headers from message
   8:   parsing address header value `Jorge Naranjo
<[email protected]>, The Boss <[email protected]>, Yank...'
   8:   extracting `domain' part from address `[email protected]'
   8:   matching value `dept.example.com'
   8:     with key `dept.example.com' => 0
(8a):  extracting `domain' part from address `[email protected]'
   8:   matching value `example.com'
(8b):    with key `dept.example.com' => 1
   8:   finishing match with result: matched
   9: jump if result is false
   9:   not jumping
  11: address test
  11:   starting `:matches' match with `i;ascii-casemap' comparator:
  11:   extracting `To' headers from message
  11:   parsing address header value `Jorge Naranjo
<[email protected]>, The Boss <[email protected]>, Yank...'
(11a):  extracting `domain' part from address `[email protected]'
  11:   matching value `dept.example.com'
(11b):     with key `*.example.com' => 1
  11:   finishing match with result: matched
  11: jump if result is true
  11:   jumping to line 13
  13: fileinto action
  13:   store message in mailbox `Company'
        ## Finished executing script 'Test'


Performed actions:

 * store message in folder: Dept
 * store message in folder: Company

Implicit keep:

  (none)

sieve-test(root): Info: final result: success
----------------------------
the rule (address :value "ne" :domain "To" "dept.example.com") is
tested against `[email protected]' (8a) successfully (8b), but the
(address :matches :domain "To" "*.example.com") is not, is instead
tested against `[email protected]' (11a) with success (11b),
but is not what we intended... ("To: Jorge Naranjo
<[email protected]>, Yanko Hernandez Alvarez
<[email protected]>" would defeat this sieve script)...

Reply via email to