Score:0

Dynamically move mails into matching mailboxes with sieve fileinto regex

gr flag

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).

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.