I'm trying to create a sieve script, which files mails into mailboxes (or sub-directories of the inbox) matching a certain subject identifier.
For example if the subject includes 123
(three digits, 0-9), the server should check if a mailbox matching the same identifier exists, such as Foobar 123
and if so, file the mail into that mailbox, otherwise have it stay in the inbox.
Checking the identifier in the subject header is no problem and I can assign the matched value to the variable ${1}
.
However, the fileinto
command does not work with the :regex
argument. As reported by sieve-test
:
error: unknown tagged argument ':regex' for the fileinto command (reported only once at first occurrence).
Here's the sieve script I currently have:
require ["fileinto", "regex", "mailbox", "variables"];
if header :regex "Subject" "([1-9][0-9][0-9])" {
fileinto :regex "INBOX\..*${1}.*";
}
Is there an approach I can take to first identify a matching inbox and assign that to the variable, or combine fileinto
with regex
?
Edit: I've also learned, that the mailboxexists
test does not seem to work with :regex
either.
error: unknown tagged argument ':regex' for the mailboxexists test (reported only once at first occurrence).