I'm using sieve rules like the following to sort logs from normal mails:
require ["fileinto", "envelope", "subaddress", "variables", "mailbox"];
# rule:[asdf-logs]
if anyof (address "From" "nagios@mail.com", address "From" "root@mail.com", address "To" "root@mail.com")
{
fileinto "INBOX.asdf.logs";
}
# rule:[asdf]
if anyof (header :contains "Delivered-To" "my@mail.com", header :contains "cc" "asdf@mail.com", header :contains "to" "asdf@mail.com")
{
fileinto "INBOX.asdf";
}
Now, if some mail is sent from nagios@mail.com
to my@mail.com
, the following two results are possible:
filing message into 'INBOX.asdf.logs'
filing message into 'INBOX.asdf'
My problem is that the mail will be sorted randomly into asdf
or asdf.logs
.
How can I solve this?
You're looking for the "stop" command.
if anyof (address "From" "nagios@mail.com", address "From" "root@mail.com", address "To" "root@mail.com")
{
fileinto "INBOX.asdf.logs";
stop;
}
Most commands, including "fileinto", don't inherently stop processing. Further rules will be processed and matched unless you explicitly execute a "stop" command. In general, once you're sure you have a message filed where you want it to go, you probably want to run stop;
so that no further portions of the sieve script are run.