Predicates

A rule is one JSON object with one key. Regexes use JavaScript syntax and are case-insensitive. String comparisons are case-insensitive.

PredicateMatches when
{"any": [p, …]}Any child matches.
{"all": [p, …]}Every child matches (and there is at least one).
{"not": p}The child does not match.
{"address": "orders@"}Local part of the receiving address equals orders. A full address matches exactly.
{"sender": "a@b.example"}From address equals.
{"sender_domain": "b.example"}From domain equals. ".b.example" also matches subdomains.
{"subject_contains": "x"} or ["x", "y"]Subject contains any of the strings.
{"subject_matches": "regex"}Subject matches.
{"header": {"name": "X-Priority", "contains": "1"}}A header with that name contains the string; matches for a regex; neither for mere presence.
{"text_contains": [...]}Sanitized body text contains any.
{"text_matches": "regex"}Body matches.
{"has_attachment": true}At least one attachment (allowed or not).
{"attachment_name_matches": "\\.pdf$"}Any attachment filename matches.
{"attachment_mime": ["application/pdf"]}Any attachment has one of the types.
{"attachment_text_contains": [...]}Any allowed attachment's text contains any of the strings.
{"auth": {"spf": "pass", "dkim": "pass", "dmarc": "pass"}}Each given result equals. Values: pass, fail, none, softfail, neutral, temperror, permerror, unknown.

Results report the path of the deciding predicate, such as rule.any[1].all[0].sender_domain.

expr: an expression, when the predicates above are not enough

{"expr": "subject.contains(\"RMA\") && attachments.exists(a, a.name.endsWith(\".pdf\"))"}. The language is CEL (cel.dev): comparisons, &&/||/!, string methods (contains, startsWith, endsWith, matches, size), list macros (exists, all, filter), in for maps. Not Turing-complete; no loops, no assignment, no reach outside the message. The expression sees:

VariableWhat
subject, text, to, reply_tostrings
from{address, name, domain}
headersa map of lower-cased header name → value (joined with ", ")
attachmentsa list of {name, mime, text, allowed}
auth{spf, dkim, dmarc}
forwarded, forwarderwhether and by whom

An expression that does not parse is refused when the rule is saved, with the parser's message. At run time a failure (a name that does not exist, a type mismatch) makes the predicate false and names itself in the deciding path; a result that is not a boolean is false. Prefer a named predicate when one says the same thing: it explains itself.

This page as Markdown.