Is there a way to set a variable to a list of strings in Sieve?

921 Views Asked by At

I want to write a Sieve filter like this:

require "fileinto";
require "imap4flags";
require "variables";

set "adresses" ["foo.com", "bar.com", "baz.com"];

if address :domain ["to", "from"] ${addresses} {
    addflag "\\Seen";
    fileinto "Spam";
}

The problem is, both the RFC and the implementation (ProtonMail's) only allow for strings:

Usage: set [MODIFIER] <name: string> <value: string>

Is there any proper or hacky way to still do something like it?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use a string as pseudo-array with separator like :, that obviously isn't a part of domain name.

require "variables";

set "addresses" ":foo.com:bar.com:baz.com:";

if address :domain :matches "to"   "*" { set "domain_to"   "${1}"; }
if address :domain :matches "from" "*" { set "domain_from" "${1}"; }

if string :contains "${addresses}" [":${domain_to}:", ":${domain_from}:"] {
    addflag "\\Seen";
    fileinto "Spam";
}