Internet-Draft JMAP Mail Rules November 2026
De Gennaro & Happel Expires 28 May 2027 [Page]
Workgroup:
JMAP
Internet-Draft:
draft-degennaro-jmap-mail-rules-00
Published:
Intended Status:
Standards Track
Expires:
Authors:
M. De Gennaro
Stalwart Labs
H. Happel
audriga

JMAP Mail Rules

Abstract

This document specifies a data model for managing server-side mail filtering rules with the JSON Meta Application Protocol (JMAP). A rule combines a set of conditions, such as the sender address or the message subject, with a set of actions, such as filing the message into a mailbox or forwarding it. The model is designed to be presented and edited through simple user interface components, and every condition and action is defined in terms of an equivalent construct of the Sieve mail filtering language, so that rules have precise and interoperable semantics and servers that implement Sieve can support this extension by translating rules into Sieve scripts.

This document also defines lists of safe and blocked senders and describes how rules interact with the JMAP VacationResponse object.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 28 May 2027.

▲

Table of Contents

1. Introduction

Server-side filtering processes messages at the time of delivery, independently of whether any client is running, and ensures that every client accessing the account observes the same outcome. The Sieve mail filtering language [RFC5228] is the standard mechanism for server-side filtering of email. It is widely deployed, it is supported by a large body of standardized extensions, and Sieve scripts can be managed through ManageSieve [RFC5804] or through JMAP [RFC9661].

Sieve, however, is a programming language. Writing a correct script requires familiarity with its syntax, its extensions, and its matching and delivery semantics; this is within reach of power users but not of most end users. In practice, end users configure server-side filters only when their mail client provides a rule editor that maps user interface components (for example, "if the sender is ..., move the message to ...") onto a generated Sieve script.

This approach works for the client that generated the script, but the resulting rules are not portable. Sieve is a general-purpose language, and an arbitrary script cannot, in general, be mapped back onto user interface components. Each client therefore relies on its own conventions, such as structured comments or a particular script layout, to recover the rules it generated, and those conventions are not understood by other clients. Rules created with one client cannot be displayed or edited with another, and a client that rewrites the active script can silently discard rules created elsewhere. Users who access their mail from several clients, or who change clients, lose the ability to manage their filters.

This document defines JMAP Mail Rules, a structured and portable representation of mail filtering rules for JMAP [RFC8620]. A rule consists of a flat set of conditions and a set of actions, each identified by a registered name and described by a small number of properties. The structure is deliberately constrained so that any rule can be represented with common user interface components, and so that any client can display and edit rules created by any other client. This document also defines lists of safe and blocked senders, and describes how rules interact with the VacationResponse object defined in Section 8 of [RFC8621].

This document does not define a conversion of arbitrary Sieve scripts into rules, does not apply rules to messages already stored in the account, and does not address filtering performed by clients.

Every condition and action defined in this document is specified in terms of an equivalent Sieve construct, using only the base Sieve language and standardized Sieve extensions. These Sieve equivalents serve two purposes. First, they give each condition and action precise semantics, reusing the matching rules, header decoding, and delivery semantics that Sieve already defines, so that all servers produce the same outcome for the same rules. Second, they allow servers that already implement Sieve to support this extension by translating rules into a Sieve script and executing it with their existing interpreter, without implementing a new filtering engine. Servers that do not implement Sieve remain free to evaluate rules by other means, provided that the outcome is the same.

1.1. Notational Conventions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

The definitions of JSON keys and datatypes in this document follow the conventions described in Section 1.1 of [RFC8620]. The terms "SetError", "PatchObject", "UTCDate" and "state string" are used as defined in [RFC8620]. The terms "Mailbox", "Email", "keyword" and "VacationResponse" are used as defined in [RFC8621]. The terms "test", "action", "implicit keep", "match type", "comparator" and "address part" are used as defined in [RFC5228].

This document also uses the following terms:

Rule:

A MailRule object (Section 4), consisting of conditions and actions.

Rule set:

All MailRule objects in an account.

Condition:

An object that describes a test applied to an incoming message (Section 5).

Action:

A property of the actions object of a rule that describes an operation performed on a matching message (Section 6).

Sender lists:

The SafeSender and BlockedSender objects in an account (Section 7).

Sieve equivalent:

The Sieve construct that defines the behaviour of a condition, an action, or another element of this specification.

Evaluation:

The processing of a single incoming message, at the time of its final delivery into the account, against the sender lists, the VacationResponse and the rule set.

User's addresses:

The set of email addresses that the server considers to belong to the owner of the account. The server determines this set; if the account has Identity objects (Section 6 of [RFC8621]), it includes at least their addresses. An Identity address whose mailbox part is "*" stands for every address in its domain. In a shared account, this is the set of addresses of the account owner, not of the authenticated user.

In Sieve fragments, text in angle brackets, such as <values>, is a placeholder for a value derived from the rule, as described in the accompanying text. String lists derived from JSON arrays are written in Sieve string list syntax, with each value escaped as described in Section 2.5.

1.2. Relationship to Sieve

This specification does not require servers to implement Sieve. The Sieve equivalents defined in this document are, however, normative with respect to behaviour: a server MUST process each incoming message as if it executed the Sieve script obtained by translating the sender lists, the VacationResponse, and the rule set as described in Section 2.5, with the semantics defined by [RFC5228] and by the Sieve extensions referenced by each construct. Where this document and the Sieve equivalent of a construct appear to disagree, the Sieve equivalent takes precedence, except where this document explicitly specifies additional or different behaviour, including:

  • the interaction with the server's spam classification (Section 2.2) and the suppression of junk filing for safe senders (Section 7.2);

  • the handling of mailboxes that do not exist, or that the user can no longer add messages to, at the time of evaluation (Section 6.5), and of a missing mailbox with the "junk" role (Section 7.2);

  • the treatment of rules that contain conditions or actions the server no longer supports (Section 4.2);

  • the requirement to prepare header field values for comparison, which Sieve only recommends (Section 3.1);

  • the matching of internationalized domain names in both A-label and U-label form (Section 3.3);

  • the test for message authentication used by the safe list, which has no Sieve equivalent (Section 7.3);

  • the recommendations not to send automatic replies to, or forward, messages classified as spam (Section 8, Section 6.3);

  • the combination of the rule set with a user-managed Sieve script (Section 8.2).

Rules apply only at the time of final delivery of a message into the account, as Sieve scripts do. They do not apply to messages created through Email/set or Email/import, to messages moved between mailboxes, or to messages that already exist when a rule is created or changed.

The Sieve fragments in this document define behaviour, not the text of a script. Servers that translate rules into Sieve MAY produce any script with equivalent behaviour.

1.3. Addition to the Capabilities Object

The capabilities object is returned as part of the JMAP Session object; see Section 2 of [RFC8620]. This document defines one additional capability URI.

1.3.1. urn:ietf:params:jmap:mailrules

This capability represents support for the MailRule, SafeSender and BlockedSender data types and associated API methods.

The value of this property in the JMAP Session "capabilities" property is an empty object.

The value of this property in an account's "accountCapabilities" property is an object that MUST contain the following information on server capabilities and permissions for that account:

supportedConditions: String[]

The condition types (Section 5) that the server supports in this account. This list MUST include every condition type that is mandatory to implement (Section 1.4). Clients MUST ignore values they do not recognize.

supportedActions: String[]

The action names (Section 6) that the server supports in this account. This list MUST include every action that is mandatory to implement (Section 1.4), except where local policy prevents the user from using it, as described in Section 1.4. Clients MUST ignore values they do not recognize.

maxRules: UnsignedInt|null

The maximum number of MailRule objects in the account, or null for no limit.

maxConditionsPerGroup: UnsignedInt|null

The maximum number of conditions in each of the matchAll, matchAny and matchNone properties of a rule, or null for no limit.

maxValuesPerCondition: UnsignedInt|null

The maximum number of values in the values property of a condition, or null for no limit.

maxMailboxesPerAction: UnsignedInt|null

The maximum number of mailboxes in the copyTo and moveTo actions, or null for no limit.

maxRedirectAddresses: UnsignedInt|null

The maximum number of addresses in the redirect action, or null for no limit.

maxSizeRuleName: UnsignedInt

The maximum length, in octets, of the name property of a rule. This MUST be at least 255.

minReplyDays: UnsignedInt

The minimum value accepted for the days property of the reply action (Section 6.4). A value of 0 indicates that the server supports replying to every message.

maxReplyDays: UnsignedInt

The maximum value accepted for the days property of the reply action. This MUST be at least 30, in line with the recommendation of Section 4.1 of [RFC5230], and MUST NOT be less than minReplyDays.

maxSizeActionText: UnsignedInt|null

The maximum size, in octets, of each of the subject, textBody and htmlBody properties of the reply action and of the reason property of the reject action, or null for no limit.

maxSenderListEntries: UnsignedInt|null

The maximum number of SafeSender objects, and separately the maximum number of BlockedSender objects, in the account, or null for no limit.

comparator: String

The comparator used for the string comparisons performed by conditions and by the sender lists in this account, as described in Section 3.1. This document defines the values "i;ascii-casemap" and "i;unicode-casemap". Future specifications may define others; clients that receive a value they do not recognize SHOULD assume "i;ascii-casemap" semantics for display purposes. Servers SHOULD NOT change this value for an account, since doing so changes the meaning of existing rules. The results of "i;unicode-casemap" also depend on the version of Unicode that the server implements (Section 4 of [RFC5051]), so a server upgrade can change the outcome of some comparisons.

1.4. Mandatory and Optional Features

Some conditions and actions have Sieve equivalents that rely on Sieve extensions that are not universally implemented. To allow servers to support this extension by translation, conditions and actions are divided into those that are mandatory to implement and those that are optional. Servers advertise the conditions and actions they support in the supportedConditions and supportedActions capability properties.

The Sieve equivalents of the mandatory conditions and actions, of the sender lists, and of the VacationResponse use only the base Sieve language [RFC5228] and the following extensions: "envelope" and "fileinto" ([RFC5228]), "body" [RFC5173], "variables" [RFC5229], "vacation" [RFC5230], "relational" [RFC5231] with the "comparator-i;ascii-numeric" comparator [RFC4790], "imap4flags" [RFC5232], "subaddress" [RFC5233], "date" [RFC5260], and "copy" [RFC3894]. The "vacation-seconds" extension [RFC6131] is needed only by servers that advertise a minReplyDays of 0. The test for message authentication used by the safe list has no standard Sieve equivalent (Section 7.3).

The following condition types are mandatory to implement: "From", "To", "Cc", "ToOrCc", "SentToMe", "RecipientAddress", "RecipientDetail", "Subject", "Body", "SubjectOrBody", "Header", "HeaderExists", "SizeOver", "SizeUnder", "Importance", "Sensitivity", "MailingList", "Keyword", "AnyKeyword", "ReceivedAfter", "ReceivedBefore" and "IsAway".

The following condition types are optional: "HasAttachment", "AttachmentName", "AttachmentType" and "MessageType" (which rely on the "mime" extension [RFC5703]), "SpamScore" (which relies on the "spamtestplus" extension [RFC5235]), and "Schedule" (which requires a server that translates rules into Sieve to update the script at every change of the UTC offset of a time zone, Section 5.5.2).

The following actions are mandatory to implement: "clearKeywords", "removeKeywords", "addKeywords", "redirect", "reply", "copyTo", "moveTo", "discard" and "stopProcessing".

The following actions are optional: "setImportance" (which relies on the "editheader" extension [RFC5293]) and "reject" (which relies on the "ereject" extension [RFC5429]).

Local policy may prevent a user from forwarding messages or from sending automatic replies. When this is the case, the server omits "redirect" or "reply", respectively, from the supportedActions property of that account, and rejects any attempt to set the corresponding action as described in Section 4.5.

2. Rule Evaluation

2.1. Evaluation Order

When a message is delivered into the account, the server evaluates, in order:

  1. the sender lists, as described in Section 7;

  2. the VacationResponse, as described in Section 8;

  3. each rule of the rule set whose isEnabled property is true, in ascending order of the position property.

Servers MUST use this order. Several properties of this specification depend on it, for example that blocked senders never receive automatic replies and that the VacationResponse takes precedence over the reply actions of rules.

Rules with the same position value are evaluated in an order chosen by the server. This order MUST be stable, that is, it MUST NOT change unless the rule set changes. Clients SHOULD assign distinct positions to rules, and SHOULD leave gaps between them (for example 10, 20, 30), so that a rule can be moved by updating its position alone. To reorder several rules, clients SHOULD update all affected rules in a single MailRule/set request, using ifInState to detect concurrent changes. The server MUST NOT change the position of a rule on its own initiative.

A change to the rule set, the sender lists or the VacationResponse applies to messages whose evaluation starts after the server has returned the response to the corresponding /set method. Each evaluation uses either the old or the new state of each object type, never a combination of both. Changes made by different method calls, even within the same request, are not guaranteed to take effect atomically with respect to each other.

Every rule whose conditions match is applied; evaluation does not stop at the first matching rule. Evaluation stops only when an action stops it: the stopProcessing and reject actions, and a match on the blocked sender list. The actions of all applied rules accumulate according to Sieve semantics. For example, if two matching rules each specify a moveTo action with different mailboxes, the message is filed into both mailboxes.

If no applied action cancels the implicit keep (Section 2.10.2 of [RFC5228]), the message is delivered to the mailbox with the "inbox" role, with the keywords in effect at the end of the evaluation, subject to Section 2.2.

If an error occurs during evaluation, the server MUST behave as described in Section 2.10.6 of [RFC5228]: all processing stops and the server performs an implicit keep. The server SHOULD perform the evaluation atomically, so that no other action takes effect when an error occurs. Sieve implementations limit the number of actions a script may perform (Section 2.10.4 of [RFC5228]); servers SHOULD choose the limits in the capability object so that no valid rule set can exceed such limits at evaluation time.

2.2. Interaction with Spam Classification

Servers commonly classify incoming messages as spam before final delivery, and file messages classified as spam into the mailbox with the "junk" role. Such classification takes place before the evaluation: the SpamScore condition tests its result, and the Header and HeaderExists conditions see any header fields that the server adds to the message before the evaluation, such as "Received", "Authentication-Results" or spam classification header fields.

For a message classified as spam, the server's filing into the junk mailbox replaces the implicit keep. That is, if the evaluation ends with the implicit keep in effect, the message is filed into the mailbox with the "junk" role instead of the mailbox with the "inbox" role, with the keywords in effect at the end of the evaluation and the "$junk" keyword (Section 4.1.1 of [RFC8621]). Actions that do not cancel the implicit keep, such as copyTo and redirect with keepCopy true, take effect in addition to this filing. If the implicit keep has been cancelled, for example by moveTo, discard, reject or redirect with keepCopy false, only the executed actions take effect. This allows users to override the server's classification with rules. Messages that match the safe list are not filed into the junk mailbox by this mechanism (Section 7.2).

2.3. Rule Matching

The conditions property of a rule contains three lists of conditions. A rule matches a message if, and only if, all of the following hold:

  • every condition in matchAll matches;

  • matchAny is empty, or at least one condition in matchAny matches;

  • no condition in matchNone matches.

A rule whose three condition lists are all empty matches every message.

This structure is intentionally flat: it supports a single conjunction, a single disjunction, and a single set of exceptions per rule. It corresponds to the condition and exception model that users commonly encounter in rule editors, and allows every rule to be presented with list-based user interface components. Rules that need more than one disjunction can be split into several rules.

2.4. Action Execution Order

Each action has an execution order, a number registered together with the action (Section 14.3.2). When a rule is applied, its actions are executed in ascending order of their execution order, independently of the order in which the properties appear in the JSON object. Because each action is a property of the actions object, each action appears at most once in a rule.

2.5. Translation to Sieve

The Sieve equivalent of the evaluation of a message is the following script:

require [<capabilities>];
<sender lists block>
<vacation block>
<rule block for each enabled rule, in evaluation order>

The <capabilities> list contains every Sieve capability required by the constructs that the script uses. The sender lists block is defined in Section 7.3, and is omitted if both lists are empty. The vacation block is defined in Section 8.1, and is omitted if the VacationResponse is not enabled.

The block of a rule has the following form:

if allof(<matchAll tests>,
         anyof(<matchAny tests>),
         not anyof(<matchNone tests>)) {
    <actions, in execution order>
}

where each test is the Sieve equivalent of a condition, and each action is the Sieve equivalent of an action. The tests of matchAll are omitted if matchAll is empty, the anyof test is omitted if matchAny is empty, the not anyof test is omitted if matchNone is empty, and the if test is replaced by true if all three lists are empty. A test list with a single test MAY be written without the enclosing allof or anyof. Since Sieve does not allow empty string lists (Section 8.2 of [RFC5228]), a translator never emits one; the conditions that can lead to an empty list define the test to use instead.

Disabled rules have no Sieve equivalent. A server that stores rules as a Sieve script MAY keep disabled rules in the script, for example by guarding them with a false test, provided they have no effect.

Translators MUST write every value derived from a rule as a Sieve quoted string, escaping the characters " and \ as described in Section 2.4.2 of [RFC5228]. Sieve strings cannot contain the NUL character, so servers MUST reject values containing U+0000 (Section 4.1).

The script always requires the "variables" extension [RFC5229], which expands ${...} inside every quoted string. Translators MUST therefore prevent variable expansion inside values. One way to do this is to define a variable holding the dollar sign, for example with set "d" "$"; at the start of the script, and to write every occurrence of ${ in a value as ${d}{; since only one pass of expansion is done (Section 3 of [RFC5229]), this produces a literal ${. Values MUST NOT be inserted into a script in any other way. The variable names "replied", "delivered" and "d", and all variable names that the translation of a vendor-specific construct uses, are reserved for the translation.

A server that stores the translation of the rule set MUST update it, before it evaluates any further message, whenever any of the following changes: the rule set, the sender lists, the VacationResponse, the user's addresses, the name of a mailbox that the translation references by name, and, for the Schedule condition, the UTC offset in effect in one of the referenced time zones.

3. Matching Semantics

3.1. Comparator

String comparisons performed by conditions and by the sender lists use the comparator advertised in the comparator property of the capability object (Section 1.3.1). Two comparators are defined for this purpose:

i;ascii-casemap

The default comparator of Sieve (Section 2.7.3 of [RFC5228]), which every Sieve implementation supports. Comparisons are case-insensitive for US-ASCII letters only; for example, "MÜLLER" and "müller" do not match.

i;unicode-casemap

The comparator defined in [RFC5051], available in Sieve through the "comparator-i;unicode-casemap" capability (Section 2.7.3 of [RFC5228]). Comparisons are case-insensitive for all of Unicode and are insensitive to differences in Unicode decomposition.

Servers SHOULD use "i;unicode-casemap", since users expect case-insensitive matching to work for text in any language. Servers that evaluate rules by translating them into Sieve can advertise "i;unicode-casemap" only if their Sieve interpreter supports it for every match type used by the conditions, including ":contains" and ":matches". Otherwise, they advertise "i;ascii-casemap". The comparator applies to the whole account; it is not selectable per condition.

The Sieve fragments in this document omit the ":comparator" argument, and therefore show the behaviour of "i;ascii-casemap". When the advertised comparator is "i;unicode-casemap", the Sieve equivalent of every test that compares a string taken from a rule, a sender list entry, or the user's addresses includes the argument :comparator "i;unicode-casemap", and the script requires the "comparator-i;unicode-casemap" capability. Tests that specify the "i;ascii-numeric" comparator, and tests that compare only fixed US-ASCII values defined by this document (such as the Importance and Sensitivity conditions), MAY omit the argument, since it has no practical effect on them.

Header field values are prepared for comparison as described in Section 2.4.2.2 of [RFC5228] and Section 2.7.2 of [RFC5228]: they are unfolded, encoded words [RFC2047] are decoded, and the result is converted to UTF-8. Servers MUST perform this preparation, although [RFC5228] only recommends it. Header field names are compared case-insensitively.

3.2. Text Operators

Conditions that compare text have an operator property whose value is one of the following strings:

is

The text is equal to the value. Sieve equivalent: the ":is" match type.

contains

The value is a substring of the text. Sieve equivalent: the ":contains" match type.

matches

The text matches the value interpreted as a wildcard pattern, in which "*" matches zero or more characters, "?" matches exactly one character, and "\" escapes the following character. Sieve equivalent: the ":matches" match type (Section 2.7.1 of [RFC5228]). The pattern is matched against the entire text. A backslash before any character other than "*", "?" or "\" has no defined meaning, and servers MUST reject values that contain one. Backslashes in a pattern are escaped again when the value is written as a Sieve string (Section 2.5).

The values property of such a condition is a list of strings. The condition matches if the operator matches any value against any of the texts being tested; when several header fields of the same name are present, each is tested. This is the string list semantics defined in Section 2.4.2.1 of [RFC5228]. A condition on a header field that is absent from the message never matches, even if one of the values is the empty string (Section 5.7 of [RFC5228]).

In the Sieve fragments of this document, <textop> denotes the match type that corresponds to the operator.

3.3. Address Operators

Conditions that compare email addresses have an operator property whose value is one of the following strings:

is

The address is equal to the value. Sieve equivalent: :is :all.

contains

The value is a substring of the address. Sieve equivalent: :contains :all.

matches

The address matches the value interpreted as a wildcard pattern, as for the text operator "matches". Sieve equivalent: :matches :all.

domain

The domain of the address is equal to the value, or is a subdomain of it. Values for this operator are domain names, without a leading "@", and MUST NOT contain the characters "*", "?", "\" or "@". Sieve equivalent: :domain :is with the values, combined with :domain :matches with each value prefixed by "*.", as shown below.

Addresses are compared without display names, comments or group names, as specified in Section 5.1 of [RFC5228]. An address that cannot be parsed never matches the "domain" operator (Section 2.7.4 of [RFC5228]).

Values for the "is" operator are addr-spec addresses, without display names. Domain names in values, whether given on their own (for the "domain" operator and in sender list entries) or as the domain part of an address (for the "is" operator, the RecipientAddress condition and the redirect action), can be internationalized. Servers SHOULD store them in A-label form ([RFC5890], [RFC5891]), in lower case, and MUST match a domain in a message regardless of whether it is written in A-label or U-label form. A translation to Sieve achieves this by including both forms of each value in the list of values. This requirement does not apply to the "contains" and "matches" operators, whose values are patterns rather than domain names.

In the Sieve fragments of this document, an address condition with operator "domain", test <test>, header list <headers> and values <values> is written as:

anyof(<test> :domain :is <headers> <values>,
      <test> :domain :matches <headers> <values with "*." prefix>)

and for the other operators as <test> <addrop> <headers> <values>, where <addrop> is the Sieve equivalent listed above.

4. Mail Rules

A MailRule object represents a single filtering rule. It has the following properties:

id: Id (immutable; server-set)

The id of the rule.

name: String

The user-visible name of the rule. It MUST NOT be empty, MUST NOT contain characters of the Unicode general category Cc, and MUST NOT be longer than maxSizeRuleName octets. Names are not required to be unique. Names do not affect evaluation.

position: UnsignedInt (default: 0)

The position of the rule in the evaluation order (Section 2.1). Rules are evaluated in ascending order of position.

isEnabled: Boolean (default: true)

Whether the rule is evaluated. Disabled rules are retained, but have no effect.

conditions: RuleConditions (default: an object with three empty lists)

The conditions of the rule (Section 2.3).

actions: RuleActions

The actions of the rule (Section 6). At least one action MUST be performed, that is, at least one property of the object MUST have a value other than null, false, or an empty set.

A RuleConditions object has the following properties:

matchAll: Condition[] (default: [])

Conditions that all have to match.

matchAny: Condition[] (default: [])

Conditions of which at least one has to match, unless the list is empty.

matchNone: Condition[] (default: [])

Conditions none of which may match.

A Condition is an object whose @type property identifies one of the condition types defined in Section 5 or registered in the registry defined in Section 14.3.1. The remaining properties of a condition depend on its type.

A RuleActions object is defined in Section 6.

Because a PatchObject cannot reference elements inside an array (Section 5.3 of [RFC8620]), clients replace condition lists as a whole when updating them.

When the server normalizes a value supplied by the client, for example by converting a domain name to lower case or a keyword to its canonical form, it MUST return the normalized value in the created or updated property of the /set response, in addition to the properties that Section 5.3 of [RFC8620] requires it to return.

When the server modifies a rule other than in response to MailRule/set, for example when a referenced mailbox is destroyed (Section 6.5), it MUST record this as a change to the rule, so that the rule is reported by MailRule/changes and the state string of the MailRule type changes.

4.1. Validation

Servers MUST reject, as described in Section 4.5, a rule that violates any of the following constraints, in addition to those stated for each property:

  • Strings MUST NOT contain the character U+0000. The subject property of the reply action MUST NOT contain characters of the Unicode general category Cc, so that it cannot introduce additional header fields.

  • Clients SHOULD send string values in Unicode Normalization Form C, since comparisons using "i;ascii-casemap" are sensitive to the normalization form.

  • Keywords MUST conform to the syntax of Section 4.1.1 of [RFC8621]. Since a Sieve interpreter ignores invalid flags (Section 2 of [RFC5232]), servers cannot rely on the interpreter to detect them.

  • Header field names MUST conform to the syntax of Section 3.6.8 of [RFC5322].

  • Properties with an enumerated set of values (operator, level, placement, kind, and the value of setImportance) MUST have one of the values defined for them.

  • Mailbox ids MUST identify existing mailboxes in the same account into which the user may add messages (myRights.mayAddItems, Section 2 of [RFC8621]). A key can be a creation id of a mailbox created earlier in the same request, which the server resolves as described in Section 5.3 of [RFC8620].

  • Addresses in the redirect action MUST be valid addr-spec addresses (Section 3.4.1 of [RFC5322]), without display names.

  • The limits advertised in the capability object MUST be respected.

A rule that the server accepts MUST be one that it can evaluate. In particular, a server that translates the rule set into a Sieve script MUST NOT accept a /set request whose resulting script it cannot compile or store, for example because it exceeds a size limit.

4.2. Unsupported Conditions and Actions

The conditions and actions that a server supports can change after a rule is created, for example when an administrator disallows forwarding. If a rule contains a condition type or an action that the server does not currently support, the server MUST NOT evaluate the rule, MUST retain it, and MUST return it unchanged in MailRule/get. A client that encounters such a rule SHOULD indicate to the user that the rule is not in effect. Updates that modify the conditions or actions properties without removing the unsupported condition or action are rejected with an "invalidProperties" SetError whose properties identify the unsupported element. Other updates, such as changes to name, position or isEnabled, and destroying the rule are always permitted. Because the rule as a whole is not evaluated, its other actions are not performed either; for example, a rule that forwards and files messages stops filing them when forwarding is disallowed.

4.3. MailRule/get

This is a standard "/get" method as described in Section 5.1 of [RFC8620].

4.4. MailRule/changes

This is a standard "/changes" method as described in Section 5.2 of [RFC8620].

4.5. MailRule/set

This is a standard "/set" method as described in Section 5.3 of [RFC8620].

The following SetError types, defined in Section 5.3 of [RFC8620], have the following specific meanings for this type.

For "create" and "update":

  • "invalidProperties": the rule is not valid (Section 4.1). This includes a condition whose @type is not listed in supportedConditions, an action not listed in supportedActions, a condition or action whose properties are not valid for its type, a rule without any performed action, a reject action combined with other actions (Section 6.7), and a reference to a mailbox that does not exist. The properties property of the SetError SHOULD identify the offending properties, as paths in the form used for the keys of a PatchObject (Section 5.3 of [RFC8620]), for example "conditions/matchAll/0/values".

  • "tooLarge": a value exceeds one of the limits maxConditionsPerGroup, maxValuesPerCondition, maxMailboxesPerAction, maxRedirectAddresses, maxSizeRuleName or maxSizeActionText, or the rule set as a whole would exceed a server limit, such as the maximum size of the translated script.

  • "forbidden": local policy does not permit the rule, for example because it forwards messages to a destination that the user is not allowed to forward to. The description property SHOULD explain the reason.

For "create":

  • "overQuota": the number of rules would exceed maxRules.

4.6. MailRule/query

This is a standard "/query" method as described in Section 5.5 of [RFC8620].

A FilterCondition object has the following properties, any of which may be omitted:

name: String

The name property of the rule contains the given string, compared using the "i;unicode-casemap" collation [RFC5051], regardless of the comparator advertised in the capability object.

isEnabled: Boolean

The isEnabled property of the rule is equal to the given value.

The following values for the property field of the Comparator object MUST be supported for sorting:

  • "position", which sorts by position and then in the evaluation order of rules with the same position (reversed when isAscending is false);

  • "name", using the collation given in the Comparator, or "i;unicode-casemap" if none is given.

When no sort is given, rules are returned in evaluation order.

4.7. MailRule/queryChanges

This is a standard "/queryChanges" method as described in Section 5.6 of [RFC8620].

5. Conditions

This section defines the condition types. For each condition type, the properties other than @type, the semantics, and the Sieve equivalent are given. Unless stated otherwise, every property listed is mandatory.

All condition objects have the following property:

@type: String

The type of the condition. This property is mandatory.

Condition types use upper camel case names. Vendor-specific condition types are described in Section 9.

5.1. Address Conditions

5.1.1. From, To, Cc and ToOrCc

These conditions test the addresses in header fields of the message.

@type: String

"From", "To", "Cc" or "ToOrCc".

operator: String (default: "is")

An address operator (Section 3.3).

values: String[]

The values to compare against. This list MUST NOT be empty.

The header fields tested are "From" for type "From", "To" for type "To", "Cc" for type "Cc", and both "To" and "Cc" for type "ToOrCc".

Sieve equivalent:

address <addrop> <headers> <values>

where <headers> is "from", "to", "cc" or ["to", "cc"], respectively.

5.1.2. SentToMe

This condition tests whether the user's addresses appear in the recipient header fields of the message.

@type: String

"SentToMe".

placement: String (default: "toOrCc")

One of the values listed below.

The placements are:

  • "to": one of the user's addresses appears in the "To" header field.

  • "cc": one of the user's addresses appears in the "Cc" header field.

  • "toOrCc": one of the user's addresses appears in the "To" or "Cc" header field.

  • "notTo": none of the user's addresses appears in the "To" header field.

  • "onlyTo": one of the user's addresses appears in the "To" header field, and the "To" and "Cc" header fields contain exactly one address in total.

Sieve equivalent, where <me> is the list of the user's addresses at the time of evaluation:

"to":     address :is :all "to" <me>
"cc":     address :is :all "cc" <me>
"toOrCc": address :is :all ["to", "cc"] <me>
"notTo":  not address :is :all "to" <me>
"onlyTo": allof(address :is :all "to" <me>,
                address :count "eq" :comparator "i;ascii-numeric"
                        ["to", "cc"] "1")

An entry of the user's addresses whose mailbox part is "*" is matched by domain instead, by replacing address :is :all <headers> <me> with anyof(address :is :all <headers> <me>, address :domain :is <headers> <wildcard domains>). If the set of the user's addresses is empty, the test address :is :all <headers> <me> is replaced by false.

5.1.3. RecipientAddress

This condition tests the envelope recipient address of the message, that is, the address to which the message was delivered. It can be used to identify messages delivered through a particular alias.

@type: String

"RecipientAddress".

operator: String (default: "is")

An address operator (Section 3.3).

values: String[]

The values to compare against. This list MUST NOT be empty.

Sieve equivalent:

envelope <addrop> "to" <values>

When a single delivery carries several envelope recipients that belong to the account, which of them the condition tests is determined by the server, as in Section 5.4 of [RFC5228].

5.1.4. RecipientDetail

This condition tests the detail part of the envelope recipient address, as defined by Section 4 of [RFC5233]. The separator between the user and detail parts is chosen by the server; for example, with "+" as separator, the detail of "user+lists@example.com" is "lists". A recipient address without a detail part never matches this condition.

@type: String

"RecipientDetail".

operator: String (default: "is")

A text operator (Section 3.2).

values: String[]

The values to compare against. This list MUST NOT be empty.

Sieve equivalent:

envelope :detail <textop> "to" <values>

5.2. Content Conditions

5.2.1. Subject

@type: String

"Subject".

operator: String (default: "contains")

A text operator (Section 3.2).

values: String[]

The values to compare against. This list MUST NOT be empty.

Sieve equivalent:

header <textop> "subject" <values>

5.2.2. Body

This condition tests the text content of the message, as defined by the ":text" body transform of [RFC5173].

@type: String

"Body".

operator: String (default: "contains")

A text operator (Section 3.2).

values: String[]

The values to compare against. This list MUST NOT be empty.

Sieve equivalent:

body :text <textop> <values>

The ":text" transform is defined on a best-effort basis, and it is unspecified whether it produces a single string or one string per body part (Section 5.3 of [RFC5173]). The result of the "is" and "matches" operators can therefore differ between servers; the "contains" operator gives consistent results, and clients SHOULD offer only that operator for this condition.

5.2.3. SubjectOrBody

This condition matches if either the Subject or the Body condition with the same operator and values would match.

@type: String

"SubjectOrBody".

operator: String (default: "contains")

A text operator (Section 3.2).

values: String[]

The values to compare against. This list MUST NOT be empty.

Sieve equivalent:

anyof(header <textop> "subject" <values>,
      body :text <textop> <values>)

5.2.4. Header

This condition tests the value of an arbitrary header field.

@type: String

"Header".

header: String

The name of the header field, without the trailing colon. It MUST be a valid field name as defined in Section 3.6.8 of [RFC5322].

operator: String (default: "contains")

A text operator (Section 3.2).

values: String[]

The values to compare against. This list MUST NOT be empty.

The condition tests the decoded value of the header field as a whole, including any comments and display names. Address header fields are better tested with the address conditions.

Sieve equivalent:

header <textop> "<header>" <values>

5.2.5. HeaderExists

This condition tests whether a header field is present.

@type: String

"HeaderExists".

header: String

The name of the header field, as for the Header condition.

Sieve equivalent:

exists "<header>"

5.2.6. HasAttachment

This condition matches if any body part of the message has a "Content-Disposition" header field with the "attachment" disposition type. It has no properties other than @type. This condition is optional.

@type: String

"HasAttachment".

Sieve equivalent:

header :mime :anychild :type :is "content-disposition" "attachment"

5.2.7. AttachmentName

This condition tests the file names of the body parts of the message, as given by the "filename" parameter of the "Content-Disposition" header field of any body part, including inline parts. File names given only by the "name" parameter of the "Content-Type" header field are not tested. Decoding of encoded parameter values is optional in [RFC5703], so non-ASCII file names may not match on every server. This condition is optional.

@type: String

"AttachmentName".

operator: String (default: "contains")

A text operator (Section 3.2).

values: String[]

The values to compare against. This list MUST NOT be empty.

Sieve equivalent:

header :mime :anychild :param "filename" <textop>
       "content-disposition" <values>

5.2.8. AttachmentType

This condition tests the media types of the body parts of the message, in "type/subtype" form, for example "application/pdf". This condition is optional.

@type: String

"AttachmentType".

operator: String (default: "is")

A text operator (Section 3.2).

values: String[]

The values to compare against. This list MUST NOT be empty.

Sieve equivalent:

header :mime :anychild :contenttype <textop> "content-type" <values>

Every body part is tested, including parts that are not attachments, such as the text of the message.

5.2.9. SizeOver and SizeUnder

These conditions test the size of the message.

@type: String

"SizeOver" or "SizeUnder".

size: UnsignedInt

The size, in octets. It MUST NOT be greater than 2147483647, the largest number that Sieve implementations are required to support (Section 2.4.1 of [RFC5228]).

"SizeOver" matches if the size of the message is strictly greater than size, and "SizeUnder" matches if it is strictly less. Sieve equivalent:

size :over <size>
size :under <size>

5.3. Classification Conditions

5.3.1. Importance

This condition tests the importance of the message, as indicated by the "Importance" header field ([RFC2156], registered by [RFC4021]) or by the widely used "X-Priority" header field.

@type: String

"Importance".

level: String

One of "high", "normal" or "low".

Sieve equivalent:

"high":   header :matches ["importance", "x-priority"]
                 ["high", "1*", "2*"]
"low":    header :matches ["importance", "x-priority"]
                 ["low", "4*", "5*"]
"normal": not header :matches ["importance", "x-priority"]
                 ["high", "low", "1*", "2*", "4*", "5*"]

A message that carries conflicting indications, such as "Importance: high" and "X-Priority: 5", matches both "high" and "low".

5.3.2. Sensitivity

This condition tests the sensitivity of the message, as indicated by the "Sensitivity" header field ([RFC2156], registered by [RFC4021]). A message without this header field, or with a value other than those listed below, has normal sensitivity.

@type: String

"Sensitivity".

level: String

One of "normal", "personal", "private" or "confidential".

Sieve equivalent:

"normal":       not header :is "sensitivity"
                ["personal", "private", "company-confidential"]
"personal":     header :is "sensitivity" "personal"
"private":      header :is "sensitivity" "private"
"confidential": header :is "sensitivity" "company-confidential"

5.3.3. MessageType

This condition tests whether the message is of a particular kind. This condition is optional.

@type: String

"MessageType".

kind: String

One of the values listed below.

The kinds and their Sieve equivalents are:

meetingRequest

The message contains an iCalendar scheduling request, as indicated by the "method" parameter of the "Content-Type" header field (Section 2.4 of [RFC6047], Section 3.2 of [RFC5546]).

header :mime :anychild :param "method" :is "content-type" "request"

meetingResponse

The message contains an iCalendar scheduling reply or counter proposal.

header :mime :anychild :param "method" :is "content-type" ["reply", "counter"]

meetingCancellation

The message contains an iCalendar scheduling cancellation.

header :mime :anychild :param "method" :is "content-type" "cancel"

deliveryReport

The message is a delivery status notification (Section 2 of [RFC3464]). This includes notifications of successful delivery.

header :mime :param "report-type" :is "content-type" "delivery-status"

readReceipt

The message is a message disposition notification (Section 3 of [RFC8098]).

header :mime :param "report-type" :is "content-type" "disposition-notification"

autoSubmitted

The message was generated automatically, such as an automatic reply, as indicated by an "Auto-Submitted" header field with a keyword other than "no" (Section 5 of [RFC3834]).

allof(exists "auto-submitted", not header :matches "auto-submitted" ["no", "no;*", "no *"])

signed

The message is signed with multipart/signed (Section 2.1 of [RFC1847]) or as opaque S/MIME signed data (Section 3.5 of [RFC8551]).

anyof(header :mime :contenttype :is "content-type" "multipart/signed", allof(header :mime :contenttype :is "content-type" "application/pkcs7-mime", header :mime :param "smime-type" :is "content-type" "signed-data"))

encrypted

The message is encrypted with multipart/encrypted (Section 2.2 of [RFC1847]) or as S/MIME enveloped data (Section 3.3 of [RFC8551], Section 3.4 of [RFC8551]).

anyof(header :mime :contenttype :is "content-type" "multipart/encrypted", allof(header :mime :contenttype :is "content-type" "application/pkcs7-mime", header :mime :param "smime-type" :is "content-type" ["enveloped-data", "authEnveloped-data"]))

Other iTIP methods, such as "publish", "refresh" or "declinecounter", are not covered by these kinds.

5.3.4. MailingList

This condition matches if the message was distributed through a mailing list, as indicated by the presence of a "List-Id" header field [RFC2919] or of any of the "List-" header fields defined in [RFC2369], which are the header fields that Section 4.6 of [RFC5230] considers. It has no properties other than @type.

@type: String

"MailingList".

Sieve equivalent:

header :matches ["list-id", "list-help", "list-subscribe",
                 "list-unsubscribe", "list-post", "list-owner",
                 "list-archive"] "*"

5.3.5. SpamScore

This condition tests the spam score assigned to the message by the server, as a percentage. This condition is optional.

@type: String

"SpamScore".

percent: UnsignedInt

A value between 1 and 100. The condition matches if the spam score of the message is greater than or equal to this value.

Sieve equivalent:

spamtest :percent :value "ge" :comparator "i;ascii-numeric" "<percent>"

A message that has not been tested for spam has a score of 0 (Section 3.2.2 of [RFC5235]), and therefore never matches this condition. The scale is defined by each server's spam classifier, so a given percentage does not necessarily have the same meaning on different servers.

5.4. Keyword Conditions

The keyword conditions test the keywords that earlier actions of the same evaluation have set on the message, for example through the addKeywords action of a preceding rule. At the start of an evaluation the message has no keywords, as is the case for the internal variable of the "imap4flags" extension (Section 3 of [RFC5232]). These conditions allow rules to build on the outcome of earlier rules. The "$notjunk" keyword set by a safe list match (Section 7.2) is visible to these conditions.

In Sieve equivalents, keywords are written as IMAP flags. The keywords "$draft", "$seen", "$flagged" and "$answered" correspond to the IMAP flags "\Draft", "\Seen", "\Flagged" and "\Answered" (Section 4.1.1 of [RFC8621]); every other keyword is written as is.

5.4.1. Keyword

@type: String

"Keyword".

keywords: String[Boolean]

The set of keywords to test, which MUST NOT be empty. Each value MUST be true. The condition matches if any of the keywords is set.

Sieve equivalent:

hasflag <keywords>

5.4.2. AnyKeyword

This condition matches if the message has at least one keyword. It has no properties other than @type.

@type: String

"AnyKeyword".

Sieve equivalent:

hasflag :matches "?*"

5.5. Date and Time Conditions

The Sieve equivalents of the conditions in this section use the "currentdate" test (Section 5 of [RFC5260]), which evaluates the time at which the message is processed rather than the "Date" header field of the message, which is set by the sender and can be forged. All "currentdate" tests in a script refer to the same point in time.

Date and time values are compared as strings. Since a fractional seconds part would make such comparisons incorrect, a date and time taken from an object that allows one, such as the VacationResponse, is rounded up to the next whole second before it is written into a script.

5.5.1. ReceivedAfter and ReceivedBefore

@type: String

"ReceivedAfter" or "ReceivedBefore".

date: UTCDate

The date and time to compare against. It MUST NOT have a fractional seconds part.

"ReceivedAfter" matches if the message is processed at or after date; "ReceivedBefore" matches if it is processed before date. Sieve equivalent, where <date> is the value of date in the format of Section 5.6 of [RFC3339] as restricted by Section 4.2 of [RFC5260], which requires the "Z" suffix:

currentdate :zone "+0000" :value "ge" "iso8601" "<date>"
currentdate :zone "+0000" :value "lt" "iso8601" "<date>"

5.5.2. Schedule

This condition matches if the message is processed within one of a set of weekly time slots, for example during working hours. This condition is optional.

@type: String

"Schedule".

slots: TimeSlot[]

The time slots. This list MUST NOT be empty.

timeZone: String|null (default: null)

The name of a time zone from the IANA Time Zone Database [TZDB] [RFC6557], in which the slots are interpreted. Servers MUST reject names they do not recognize. If a name later becomes an alias of another zone, the server uses that zone; if it is removed, the condition never matches. If null, the slots are interpreted in the server's default time zone, which clients cannot discover; clients SHOULD therefore always set this property.

A TimeSlot object has the following properties:

days: String[Boolean]

The set of days of the week on which the slot starts. Keys are the day values defined for the NDay object in Section 4.3.3 of [RFC8984] ("mo", "tu", "we", "th", "fr", "sa" and "su"). Each value MUST be true. This set MUST NOT be empty.

start: String

The start time of the slot, inclusive, in "HH:MM" format with a 24-hour clock, with two digits for the hours ("00" to "23") and two digits for the minutes ("00" to "59").

end: String

The end time of the slot, exclusive, in the same format as start. The value "24:00" denotes the end of the day. An end of "00:00" is first replaced by "24:00"; after this replacement, if end is earlier than start, the slot extends past midnight into the following day, and end MUST NOT be equal to start.

The Sieve equivalent of a slot that does not extend past midnight is:

allof(currentdate :zone "<offset>" :is "weekday" <weekdays>,
      currentdate :zone "<offset>" :value "ge" "time" "<start>:00",
      currentdate :zone "<offset>" :value "lt" "time" "<end>:00")

where <weekdays> is the list of Sieve weekday numbers of days ("0" for Sunday, "1" for Monday, and so on, as defined in Section 4.2 of [RFC5260]). The upper bound is omitted when end is "24:00". A slot that extends past midnight is equivalent to two slots: one from start to "24:00" on days, and one from "00:00" to end on the days that follow each of days. The condition is the anyof of the equivalents of all slots.

Sieve accepts only numeric time zone offsets (Section 4.1 of [RFC5260]). <offset> is therefore the UTC offset, in "+hhmm" or "-hhmm" form, that is in effect in timeZone at the time of evaluation. Because the offset in effect is used, gaps and overlaps caused by daylight saving time transitions need no special handling. A server that translates rules into Sieve MUST update the script no later than the instant at which the offset changes (Section 2.5). When timeZone is null, the :zone argument is omitted, and the server's default time zone applies.

5.5.3. IsAway

This condition matches if the VacationResponse of the account is in effect, that is, if its isEnabled property is true and the message is processed at or after its fromDate (if not null) and before its toDate (if not null) (Section 8 of [RFC8621]). It has no properties other than @type.

@type: String

"IsAway".

Sieve equivalent, if isEnabled is true:

allof(currentdate :zone "+0000" :value "ge" "iso8601" "<fromDate>",
      currentdate :zone "+0000" :value "lt" "iso8601" "<toDate>")

where each test is omitted if the corresponding property is null, and the whole condition is true if both are null. If isEnabled is false, or if the account does not support the VacationResponse object, the Sieve equivalent is false.

6. Actions

A RuleActions object has one property for each action. Each action is identified by its property name, which is registered in the registry defined in Section 14.3.2 or is a vendor-specific name (Section 9). A property that is absent, null, false, or an empty set denotes that the action is not performed. Action names use lower camel case.

The actions defined by this document are listed in the following table, in execution order (Section 2.4):

Table 1: Actions
Action Execution Order Sieve Capabilities
clearKeywords 100 imap4flags
removeKeywords 200 imap4flags
addKeywords 300 imap4flags
setImportance 400 editheader
redirect 500 copy (if keepCopy is true), variables
reply 600 vacation, variables, vacation-seconds (if days is 0)
copyTo 700 fileinto, copy, variables
moveTo 800 fileinto, variables
discard 900 none
reject 1000 ereject, variables
stopProcessing 1100 none

Keyword actions are executed before filing actions, so that keywords set by a rule apply to the copies of the message filed by the same rule and by later rules (Section 3 of [RFC5232]).

Actions accumulate across rules according to Sieve semantics. In particular:

6.1. Keyword Actions

clearKeywords: Boolean (default: false)

Removes all keywords set by earlier actions in the same evaluation.

removeKeywords: String[Boolean] (default: {})

Removes the given keywords. Each value MUST be true.

addKeywords: String[Boolean] (default: {})

Adds the given keywords. Each value MUST be true.

A keyword MUST NOT appear in both removeKeywords and addKeywords. Keywords are written in Sieve equivalents as described in Section 5.4. Sieve equivalents (Section 3.1 of [RFC5232], Section 3.2 of [RFC5232] and Section 3.3 of [RFC5232]):

setflag "";
removeflag <keywords>;
addflag <keywords>;

The keywords in effect when a filing action is executed are set on the copy of the message that it delivers, and the keywords in effect at the end of the evaluation are set on the message delivered by implicit keep (Section 3 of [RFC5232]). Keywords added by a later rule do not apply to copies already filed. If the same mailbox is filed more than once, the last set of keywords applies. Forwarded messages do not carry keywords.

6.2. setImportance

setImportance: String|null (default: null)

Sets the importance of the message to "high", "normal" or "low", by replacing its "Importance" and "X-Priority" header fields. This action is optional.

Sieve equivalent (Section 5 of [RFC5293]):

deleteheader "importance";
deleteheader "x-priority";
addheader "Importance" "<level>";

6.3. redirect

redirect: Redirect|null (default: null)

Forwards the message to other addresses.

A Redirect object has the following properties:

addresses: String[]

The addresses to forward the message to, as addr-spec addresses without display names. This list MUST NOT be empty, and MUST NOT contain more than maxRedirectAddresses addresses. Addresses with a non-ASCII local part require SMTPUTF8 [RFC6531]; a server that does not support forwarding to them rejects them with an "invalidProperties" SetError.

keepCopy: Boolean (default: true)

Whether the message is also delivered to the account. If false, the implicit keep is cancelled, and the message is delivered to the account only if another action files it.

Sieve equivalent, for each address:

redirect :copy "<address>";     (keepCopy is true)
redirect "<address>";           (keepCopy is false)
set "delivered" "1";

The requirements of Section 4.2 of [RFC5228] apply, in particular those on loop control and on an empty envelope sender. A redirect that the server ignores at evaluation time for policy reasons, for example because a per-destination rate limit has been reached, does not cancel the implicit keep. Servers SHOULD NOT forward messages that they classify as spam, since doing so harms the reputation of the forwarding server; such a redirect is ignored in the same way. Servers MAY require the owner of a destination address to confirm that they accept forwarded mail before a rule forwards to it, and reject rules with unconfirmed destinations with a "forbidden" SetError whose description explains this. The delivered variable is used by the reject action (Section 6.7), and MAY be omitted from the translation if the rule set contains no reject action.

6.4. reply

reply: Reply|null (default: null)

Sends an automatic reply to the sender of the message.

A Reply object has the following properties:

subject: String|null (default: null)

The subject of the reply. If null, the server chooses a subject, as described in Section 5.3 of [RFC5230].

textBody: String

The plain text body of the reply.

htmlBody: String|null (default: null)

The HTML body of the reply. If not null, the reply is a "multipart/alternative" message containing both bodies.

days: UnsignedInt (default: 7)

The minimum number of days between two replies sent by this rule to the same sender. A value of 0 means that a reply is sent for every message. The value MUST NOT be less than minReplyDays or greater than maxReplyDays. If the default value is less than minReplyDays, the server uses minReplyDays instead.

The reply action follows the semantics of the Sieve "vacation" action [RFC5230], including its restrictions on the messages that receive a reply and the requirements of [RFC3834]. In particular, a reply MUST NOT be sent to messages that do not list one of the user's addresses as a recipient (Section 4.5 of [RFC5230]), and SHOULD NOT be sent to messages from mailing lists or to automatically submitted messages (Section 4.6 of [RFC5230]). The reply is sent to the envelope sender of the message, not to the addresses in its "From" or "Reply-To" header fields, and no reply is sent if the envelope sender is empty (Section 5.1 of [RFC5230]).

A Sieve script can execute at most one "vacation" action (Section 4.7 of [RFC5230]). For this reason, at most one automatic reply is sent for each message: once a reply action or the VacationResponse (Section 8) has been executed in an evaluation, subsequent reply actions in the same evaluation are not executed. This holds even if the earlier reply was suppressed because the same sender received a reply recently.

Sieve equivalent:

if string :is "${replied}" "" {
    set "replied" "1";
    vacation :days <days> :handle "<handle>" [:addresses <me>]
             [:subject "<subject>"] [:mime] "<reason>";
}

where <me> is the list of the user's addresses, excluding entries whose mailbox part is "*", and omitted if that list is empty (the final envelope recipient check of Section 4.5 of [RFC5230] covers wildcard entries), and <handle> is a string that identifies both the rule and the content of the reply, for example the id of the rule combined with a digest of the subject, textBody and htmlBody properties, so that editing the reply starts a new tracking period (Section 4.2 of [RFC5230]). <reason> is the text body. If htmlBody is not null, the :mime tag is used and <reason> is a MIME entity (Section 4.4 of [RFC5230]) with a "multipart/alternative" body containing the text and HTML bodies. If days is 0, :seconds 0 (Section 2 of [RFC6131]) is used in place of :days.

6.5. copyTo and moveTo

copyTo: Id[Boolean] (default: {})

Files a copy of the message into each of the given mailboxes, without cancelling the implicit keep. Each value MUST be true.

moveTo: Id[Boolean] (default: {})

Files the message into each of the given mailboxes, cancelling the implicit keep. Each value MUST be true.

The keys are Mailbox ids. A rule MUST NOT reference more than maxMailboxesPerAction mailboxes in each of these properties. Sieve equivalent, for each mailbox:

fileinto :copy "<mailbox name>";     (copyTo)
fileinto "<mailbox name>";           (moveTo)
set "delivered" "1";

where <mailbox name> is the full hierarchical name of the mailbox (Section 4.1 of [RFC5228]), and the delivered variable is used as for the redirect action. A server that translates rules into Sieve updates the script when a referenced mailbox is renamed (Section 2.5), or additionally passes the mailbox id with the ":mailboxid" argument (Section 4 of [RFC9042]), in which case the name is used only if no mailbox with that id exists.

Filing a message into the mailbox with the "junk" role does not set the "$junk" keyword; rules that need it use the addKeywords action.

When a mailbox referenced by a rule is destroyed, the server MUST remove it from the rule. If the mailbox was referenced by moveTo, or if the rule would be left without a performed action, the server MUST also set isEnabled to false, so that the change in behaviour is visible to the user rather than silent. If a referenced mailbox does not exist at the time of evaluation, or the owner of the account can no longer add messages to it, the server MUST behave as if the corresponding filing action delivered the message to the mailbox with the "inbox" role, which is one of the outcomes that Section 4.1 of [RFC5228] permits.

6.6. discard

discard: Boolean (default: false)

Cancels the implicit keep. Unless another action delivers the message, the message is silently dropped.

Sieve equivalent (Section 4.4 of [RFC5228]):

discard;

6.7. reject

reject: Reject|null (default: null)

Refuses the message, returning the given reason to the sender. This action is optional.

A Reject object has the following property:

reason: String

The text explaining why the message was refused.

A rule with a reject action MUST NOT specify any other action, except stopProcessing. Evaluation stops after a reject action is performed, regardless of the value of stopProcessing.

The Sieve equivalent uses the "ereject" action, which refuses the message during the SMTP or LMTP transaction when possible and otherwise sends a delivery status notification (Section 2.1 of [RFC5429]). "ereject" is preferred over "reject" because it minimizes backscatter, and because Section 2.3 of [RFC5429] recommends it for rejections that result from anti-spam tests, such as a rule with a SpamScore condition. A reason containing non-ASCII characters may prevent a refusal at the protocol level (Section 2.2 of [RFC5429]), in which case a notification is sent instead.

Like "reject", the "ereject" action is incompatible with the "vacation" action, and its use together with actions that deliver the message is NOT RECOMMENDED (Section 2.4 of [RFC5429]). For this reason, the reject action is not performed if an automatic reply (Section 6.4, Section 8) has already been executed in the same evaluation, or if an earlier rule has already filed or forwarded the message. In that case the rule has no effect, other than stopping the evaluation if its stopProcessing property is true. Since the VacationResponse executes for every message that arrives while it is in effect, reject actions are not performed while the user is away; clients SHOULD inform users of this when they configure a reject rule or a VacationResponse.

Sieve equivalent:

if allof(string :is "${replied}" "",
         string :is "${delivered}" "") {
    ereject "<reason>";
    stop;
}

6.8. stopProcessing

stopProcessing: Boolean (default: false)

Stops the evaluation after the actions of this rule. Rules that follow are not evaluated.

Sieve equivalent:

stop;

7. Safe and Blocked Senders

The sender lists are two lists of addresses and domains that users commonly maintain to override the server's spam classification. A sender on the safe list is never treated as spam, and messages from a sender on the blocked list are filed as spam. Each list entry is a separate object, so that clients can add and remove entries without conflicting with each other.

7.1. Matching

Each entry of a sender list has an address property whose value is either:

  • an email address, such as "user@example.com", which matches messages whose "From" header field contains that address; or

  • a domain name preceded by "@", such as "@example.com", which matches messages whose "From" header field contains an address in that domain or in any of its subdomains.

Values are compared using the comparator advertised in the capability object, as for the address operators "is" and "domain", respectively (Section 3.3). A domain entry does not match its parent domain: "@sub.example.com" does not match addresses in "example.com". An entry can be one of the user's own addresses.

The same address can appear in both lists; the precedence rules below determine the outcome.

7.2. Semantics

A message matches the safe list if its "From" header field contains exactly one address, that address matches a SafeSender entry, and the server has determined that the message was authenticated as originating from the domain of that address. How the server makes this determination is a matter of local policy; examples include a DMARC "pass" result with an aligned "From" domain (Section 3.2.10 of [RFC9989]), or the message having been submitted by an authenticated user of the server who is authorized to use that "From" address. Mechanisms such as DMARC authenticate the domain of the address, not its local part; a safe address entry is therefore no stronger than its domain with respect to senders authorized to use that domain. Because the "From" header field is easily forged, a server MUST NOT treat a message as matching the safe list unless it has authenticated it.

A message matches the blocked list if any address in its "From" header field matches a BlockedSender entry. No authentication is required.

If a message matches both lists, the safe list takes precedence. Since a match on the safe list requires authentication, an unauthenticated message whose sender appears in both lists is treated as blocked.

When a message matches the safe list, the server MUST NOT file it into the mailbox with the "junk" role as a result of its spam classification (Section 2.2), and sets the "$notjunk" keyword (Section 4.1.1 of [RFC8621]). The suppression of junk filing does not depend on the keyword: it applies even if a rule later removes "$notjunk". Evaluation continues with the VacationResponse and the rules. Rules can still file such a message into any mailbox, including the junk mailbox, and SpamScore conditions still test the score assigned by the server.

When a message matches the blocked list, and does not match the safe list, it is filed into the mailbox with the "junk" role, the "$junk" keyword (Section 4.1.1 of [RFC8621]) is set on it, and evaluation stops. In particular, no automatic reply is sent and no rules are applied. If the account has no mailbox with the "junk" role, the message is delivered to the mailbox with the "inbox" role with the "$junk" keyword set.

7.3. Sieve Equivalent

The Sieve equivalent of the sender lists is:

if allof(<authenticated>,
         anyof(address :is :all "from" <safe addresses>,
               address :domain :is "from" <safe domains>,
               address :domain :matches "from" <safe subdomains>)) {
    addflag "$notjunk";
} elsif anyof(address :is :all "from" <blocked addresses>,
              address :domain :is "from" <blocked domains>,
              address :domain :matches "from" <blocked subdomains>) {
    fileinto :flags "$junk" "<junk mailbox name>";
    stop;
}

where <safe domains> and <blocked domains> are the domain entries without the leading "@", and <safe subdomains> and <blocked subdomains> are the same domains prefixed with "*.". Tests with empty lists are omitted, and the first or second branch is omitted if the corresponding list is empty. <junk mailbox name> is the name of the mailbox with the "junk" role; a translator can also use fileinto :specialuse "\\Junk" ([RFC8579]). If the account has no such mailbox, the fileinto action is replaced by addflag "$junk";. The fileinto action requires the "fileinto" and "imap4flags" capabilities.

There is no standard Sieve test for message authentication. <authenticated> denotes a test that is true if the server authenticated the message and its "From" header field contains a single address, as described in Section 7.2. A server that translates the sender lists into Sieve can implement it, for example, with a vendor-specific item of the "environment" extension (Section 4.2 of [RFC5183]). The suppression of junk filing for safe senders is performed by the server outside the script.

7.4. SafeSender and BlockedSender Objects

A SafeSender object represents an entry of the safe list, and a BlockedSender object represents an entry of the blocked list. Both have the following properties:

id: Id (immutable; server-set)

The id of the entry.

address: String (immutable)

The email address or "@"-prefixed domain name of the entry, as described in Section 7.1. The server MAY normalize the value, for example by converting it to lower case, and MUST return the normalized value.

Each list MUST NOT contain more than one entry with the same normalized address. Future queries, filters and comparisons use the normalized value.

7.5. SafeSender/get and BlockedSender/get

These are standard "/get" methods as described in Section 5.1 of [RFC8620].

7.6. SafeSender/changes and BlockedSender/changes

These are standard "/changes" methods as described in Section 5.2 of [RFC8620].

7.7. SafeSender/set and BlockedSender/set

These are standard "/set" methods as described in Section 5.3 of [RFC8620]. Because the address property is immutable, entries cannot be modified; clients destroy an entry and create a new one instead. An update that changes address is rejected with an "invalidProperties" SetError.

The following SetError types, defined in Section 5.3 of [RFC8620] and, for "alreadyExists", in Section 5.4 of [RFC8620], have the following specific meanings for these types.

For "create":

  • "invalidProperties": the address property is not a valid email address or "@"-prefixed domain name.

  • "alreadyExists": the same list already contains an entry with the same normalized address. The SetError MUST include an existingId property with the id of that entry. An entry in the other list does not cause this error.

  • "overQuota": the list would contain more than maxSenderListEntries entries.

7.8. SafeSender/query and BlockedSender/query

These are standard "/query" methods as described in Section 5.5 of [RFC8620].

A FilterCondition object has the following property, which may be omitted:

address: String

The address property of the entry contains the given string, compared using the "i;unicode-casemap" collation [RFC5051].

The following value for the property field of the Comparator object MUST be supported for sorting: "address", using the collation given in the Comparator, or "i;unicode-casemap" if none is given.

7.9. SafeSender/queryChanges and BlockedSender/queryChanges

These are standard "/queryChanges" methods as described in Section 5.6 of [RFC8620].

8. Interaction with VacationResponse

A server that supports both this extension and the VacationResponse object (Section 8 of [RFC8621]) evaluates the VacationResponse as part of the same evaluation as the sender lists and the rule set, at the position described in Section 2.1. As a consequence:

Servers SHOULD NOT send a vacation response, or execute a reply action, for messages that they classify as spam, since the envelope sender of such messages is often forged.

8.1. Sieve Equivalent

The Sieve equivalent of a VacationResponse whose isEnabled property is true is:

if allof(currentdate :zone "+0000" :value "ge" "iso8601" "<fromDate>",
         currentdate :zone "+0000" :value "lt" "iso8601" "<toDate>") {
    set "replied" "1";
    vacation [:addresses <me>] [:subject "<subject>"]
             [:mime] "<reason>";
}

where each currentdate test is omitted if the corresponding property is null, the if test is replaced by true if both are null, <me> is as for the reply action, and <reason> is derived from the textBody and htmlBody properties as for the reply action (Section 6.4). If textBody is null, the server derives a plain text body from htmlBody, and if both are null, it uses a body of its choice, as Section 8 of [RFC8621] describes. If subject is null, the :subject argument is omitted (Section 5.3 of [RFC5230]). The interval between replies to the same sender is chosen by the server, as for a "vacation" action without the :days argument (Section 4.1 of [RFC5230]).

8.2. Coexistence with User Sieve Scripts

Servers that support JMAP Sieve [RFC9661] or ManageSieve [RFC5804] also let users manage Sieve scripts directly, of which at most one is active (Section 2.1 of [RFC9661]). The sender lists, the VacationResponse and the rule set MUST be applied to every message delivered into the account, independently of which Sieve script, if any, is active. Activating or deactivating a user script MUST NOT affect them.

When the account has an active user script, the server MUST behave as if that script were included at the end of the translation of the rule set with include :personal "<name>" (Section 3.2 of [RFC6609]). Consequently, the actions of both accumulate; a stop executed by the translation, such as a stopProcessing or reject action or a match on the blocked list, also prevents the user script from running; and the implicit keep is cancelled if either cancels it. If an action of the user script would cause an error only because of an action already executed by the translation, such as a second "vacation" action (Section 4.7 of [RFC5230]), the server ignores that action of the user script instead of treating it as an error.

The translation of the rule set is not a user script. Servers SHOULD NOT represent it as a SieveScript object. A server that does so, for example to let users inspect it, MUST NOT allow it to be modified, destroyed, activated or deactivated through SieveScript/set or ManageSieve, and MUST reject such requests with a "forbidden" SetError (or the equivalent ManageSieve response), whose description SHOULD indicate that the rules are managed through MailRule/set. A server that supports this extension implements the VacationResponse as part of the rule set; Section 4 of [RFC9661], which applies to a VacationResponse implemented as a user-visible Sieve script, therefore does not apply.

9. Extensibility

New condition types and actions can be defined by future specifications and registered in the registries defined in Section 14.3. The registration of an action includes its execution order, which determines where it executes relative to the other actions.

Vendors MAY define condition types and actions without registration, using a name of the form <domain>:<name>, where <domain> is a domain name controlled by the vendor, for example "example.com:Approved" for a condition type or "example.com:notify" for an action. Registered names never contain a colon. Vendor-specific names appear in supportedConditions and supportedActions like registered ones. The execution order of a vendor-specific action is a positive integer defined by the vendor; actions with the same execution order are executed in ascending order of their names, compared as octet strings.

Every registered condition type and action MUST be defined in terms of a Sieve equivalent, using either the base Sieve language or Sieve extensions; vendor-specific ones SHOULD be. Condition types and actions defined by other specifications are optional to implement.

The values of enumerated properties of the conditions and actions defined in this document (operator, placement, level, kind and the value of setImportance) form closed sets. New values, and new properties of existing condition types and actions, can only be added by a specification that updates this document; other extensions define new condition types or actions instead. Servers MUST reject conditions and actions that contain properties they do not recognize.

A server MUST reject, as described in Section 4.5, a rule that contains a condition type or an action that it does not support. A client can receive rules containing condition types or actions that it does not recognize, for example when they were created by a client that supports a newer specification. Such a client MUST preserve these conditions and actions, and any properties it does not recognize, when it updates the rule (for example, when it replaces the matchAll list, it keeps the elements it does not recognize, in their original relative order), and SHOULD present the rule to the user as one that it cannot fully edit, rather than omitting it.

10. Examples

10.1. Capability

The following is an example of the capability object in an account's "accountCapabilities" property:

"urn:ietf:params:jmap:mailrules": {
  "supportedConditions": [
    "From", "To", "Cc", "ToOrCc", "SentToMe", "RecipientAddress",
    "RecipientDetail", "Subject", "Body", "SubjectOrBody", "Header",
    "HeaderExists", "HasAttachment", "AttachmentName",
    "AttachmentType", "SizeOver", "SizeUnder", "Importance",
    "Sensitivity", "MessageType", "MailingList", "SpamScore",
    "Keyword", "AnyKeyword", "ReceivedAfter", "ReceivedBefore",
    "Schedule", "IsAway"
  ],
  "supportedActions": [
    "clearKeywords", "removeKeywords", "addKeywords",
    "setImportance", "redirect", "reply", "copyTo", "moveTo",
    "discard", "reject", "stopProcessing"
  ],
  "maxRules": 256,
  "maxConditionsPerGroup": 32,
  "maxValuesPerCondition": 64,
  "maxMailboxesPerAction": 16,
  "maxRedirectAddresses": 5,
  "maxSizeRuleName": 255,
  "minReplyDays": 0,
  "maxReplyDays": 365,
  "maxSizeActionText": 4096,
  "maxSenderListEntries": 1024,
  "comparator": "i;unicode-casemap"
}

10.2. Creating a Rule

The client creates a rule that files messages from a mailing list into a mailbox and marks them as read:

[[ "MailRule/set", {
  "accountId": "a1",
  "create": {
    "k1": {
      "name": "Project list",
      "position": 10,
      "conditions": {
        "matchAll": [{
          "@type": "Header",
          "header": "List-Id",
          "operator": "contains",
          "values": ["project.lists.example.org"]
        }]
      },
      "actions": {
        "addKeywords": { "$seen": true },
        "moveTo": { "M7f2": true },
        "stopProcessing": true
      }
    }
  }
}, "c1" ]]

The server responds:

[[ "MailRule/set", {
  "accountId": "a1",
  "oldState": "s41",
  "newState": "s42",
  "created": {
    "k1": {
      "id": "R1",
      "isEnabled": true
    }
  }
}, "c1" ]]

The server returns the id and the defaulted isEnabled property. The client omitted matchAny and matchNone, which default to empty lists. The server does not return them, since they are part of the conditions property, which the client sent and the server did not change (Section 5.3 of [RFC8620]).

If the mailbox "M7f2" is named "Lists/Project", the Sieve equivalent of the rule is:

if header :contains "list-id" "project.lists.example.org" {
    addflag "\\Seen";
    fileinto "Lists/Project";
    stop;
}

10.3. Managing Sender Lists

The client adds a domain to the safe list and an address to the blocked list. The blocked address already exists:

[[ "SafeSender/set", {
  "accountId": "a1",
  "create": {
    "k1": { "address": "@partner.example" }
  }
}, "c1" ],
[ "BlockedSender/set", {
  "accountId": "a1",
  "create": {
    "k2": { "address": "Offers@Shop.Example" }
  }
}, "c2" ]]

The server responds:

[[ "SafeSender/set", {
  "accountId": "a1",
  "oldState": "s7",
  "newState": "s8",
  "created": {
    "k1": { "id": "S3", "address": "@partner.example" }
  }
}, "c1" ],
[ "BlockedSender/set", {
  "accountId": "a1",
  "oldState": "b2",
  "newState": "b2",
  "notCreated": {
    "k2": {
      "type": "alreadyExists",
      "existingId": "B1"
    }
  }
}, "c2" ]]

10.4. A Complete Rule Set

This example shows a complete set of sender lists, a VacationResponse, and two rules, together with their Sieve equivalent.

The sender lists contain the SafeSender "@partner.example" and the BlockedSender "offers@shop.example". The VacationResponse is:

{
  "id": "singleton",
  "isEnabled": true,
  "fromDate": "2026-12-20T00:00:00Z",
  "toDate": "2027-01-05T00:00:00Z",
  "subject": "Out of office",
  "textBody": "I am away until January 5.",
  "htmlBody": null
}

The first rule handles invoices sent with an attachment by the finance department of a supplier, or by its billing system, unless they come from a mailing list or look like spam. It flags them, files them into the "Finance/Invoices" mailbox (id "M3"), acknowledges their receipt, and stops evaluation:

{
  "id": "R1",
  "name": "Supplier invoices",
  "position": 10,
  "isEnabled": true,
  "conditions": {
    "matchAll": [
      { "@type": "Subject", "operator": "contains",
        "values": ["invoice", "receipt"] },
      { "@type": "HasAttachment" }
    ],
    "matchAny": [
      { "@type": "From", "operator": "domain",
        "values": ["finance.supplier.example"] },
      { "@type": "From", "operator": "is",
        "values": ["billing@supplier.example"] }
    ],
    "matchNone": [
      { "@type": "MailingList" },
      { "@type": "SpamScore", "percent": 50 }
    ]
  },
  "actions": {
    "addKeywords": { "$flagged": true, "finance": true },
    "reply": {
      "subject": "Invoice received",
      "textBody": "Thank you, your invoice has been received.",
      "htmlBody": null,
      "days": 30
    },
    "moveTo": { "M3": true },
    "stopProcessing": true
  }
}

The second rule forwards high-importance messages sent directly to the user to a colleague while the user is away, keeping a copy:

{
  "id": "R2",
  "name": "Urgent while away",
  "position": 20,
  "isEnabled": true,
  "conditions": {
    "matchAll": [
      { "@type": "IsAway" },
      { "@type": "Importance", "level": "high" },
      { "@type": "SentToMe", "placement": "to" }
    ],
    "matchAny": [],
    "matchNone": []
  },
  "actions": {
    "redirect": {
      "addresses": ["deputy@example.com"],
      "keepCopy": true
    }
  }
}

Assuming that the user's only address is "jane@example.com", that the server (unlike the one in Section 10.1) advertises the "i;ascii-casemap" comparator, that the account has a mailbox named "Junk" with the "junk" role, and that the server represents message authentication with the vendor-specific environment item "vnd.example.authenticated", the Sieve equivalent is:

require ["comparator-i;ascii-numeric", "copy", "date",
         "environment", "fileinto", "imap4flags", "mime",
         "relational", "spamtestplus", "vacation", "variables"];

if allof(environment :is "vnd.example.authenticated" "yes",
         anyof(address :domain :is "from" "partner.example",
               address :domain :matches "from" "*.partner.example")) {
    addflag "$notjunk";
} elsif address :is :all "from" "offers@shop.example" {
    fileinto :flags "$junk" "Junk";
    stop;
}

if allof(currentdate :zone "+0000"
                     :value "ge" "iso8601" "2026-12-20T00:00:00Z",
         currentdate :zone "+0000"
                     :value "lt" "iso8601" "2027-01-05T00:00:00Z") {
    set "replied" "1";
    vacation :addresses "jane@example.com" :subject "Out of office"
             "I am away until January 5.";
}

if allof(header :contains "subject" ["invoice", "receipt"],
         header :mime :anychild :type :is "content-disposition"
                "attachment",
         anyof(address :domain :is "from" "finance.supplier.example",
               address :domain :matches "from"
                       "*.finance.supplier.example",
               address :is :all "from" "billing@supplier.example"),
         not anyof(header :matches ["list-id", "list-help",
                        "list-subscribe", "list-unsubscribe",
                        "list-post", "list-owner", "list-archive"] "*",
                   spamtest :percent :value "ge"
                            :comparator "i;ascii-numeric" "50")) {
    addflag ["\\Flagged", "finance"];
    if string :is "${replied}" "" {
        set "replied" "1";
        vacation :days 30 :handle "R1-3f2a"
                 :addresses "jane@example.com"
                 :subject "Invoice received"
                 "Thank you, your invoice has been received.";
    }
    fileinto "Finance/Invoices";
    stop;
}

if allof(allof(currentdate :zone "+0000" :value "ge"
                           "iso8601" "2026-12-20T00:00:00Z",
               currentdate :zone "+0000" :value "lt"
                           "iso8601" "2027-01-05T00:00:00Z"),
         header :matches ["importance", "x-priority"]
                ["high", "1*", "2*"],
         address :is :all "to" "jane@example.com") {
    redirect :copy "deputy@example.com";
}

Since no rule contains a reject action, the translation does not set the delivered variable. During the user's absence, invoices are still flagged and filed, but their senders receive at most the vacation response, and not the acknowledgement of the first rule, since at most one automatic reply is sent for each message.

11. Operational Considerations

Migration:

Many deployments contain Sieve scripts generated by the rule editors of existing clients. This document does not define how such scripts are converted into rules. A server MAY convert scripts in formats it recognizes; otherwise such scripts continue to run as user scripts alongside the rule set (Section 8.2). Clients that generate Sieve scripts for their rule editors are encouraged to use this extension instead when the server supports it, and can offer users to move their existing rules.

Administrative policy:

When an administrator withdraws support for a condition or action, for example by disallowing forwarding, every rule that uses it stops being evaluated as a whole (Section 4.2), including its other actions. Administrators need to be aware of this effect.

Comparator support:

Deployed Sieve implementations differ in whether they implement "i;unicode-casemap", and whether they list it among their capabilities. Implementers that translate rules into Sieve need to verify that their interpreter applies the comparator to every match type before advertising it (Section 3.1).

Diagnostics:

This document provides no means to test rules against a message or to determine which rules acted on a delivered message. Servers can provide such facilities by other means.

12. Security Considerations

All security considerations of [RFC8620] and [RFC8621] apply to this specification, as do the security considerations of [RFC5228] and of each Sieve extension referenced by the Sieve equivalents of the conditions and actions in use. Additional considerations specific to mail rules are detailed below.

12.1. Script Injection

Servers that translate rules into Sieve scripts insert values provided by clients into the script. A value that is not properly escaped could alter the structure of the script, adding tests or actions that the user did not request, such as forwarding messages to a third party. Translators MUST escape values as described in Section 2.5, and MUST validate header names, keywords, domain names and other constrained values before inserting them.

12.2. Forwarding

The redirect action sends messages to addresses outside the control of the account owner. An attacker who obtains temporary access to an account, for example through a stolen access token, can create a rule that silently forwards all future messages, retaining access to the user's mail after the compromise has been remediated. Servers SHOULD allow administrators to restrict forwarding, for example to particular domains, SHOULD record the creation and modification of forwarding rules, and MAY notify the user when such a rule is created. Clients SHOULD make forwarding rules clearly visible to users. Forwarded messages can fail sender authentication checks at their destination; servers SHOULD apply to them the same outbound measures that they apply to other forwarded mail.

12.3. Automatic Replies and Rejections

Automatic replies and rejections generate messages towards the envelope sender of incoming messages. Since the envelope sender of spam is often forged, they can cause backscatter to uninvolved parties. Automatic replies can also cause mail loops. The reply action and the VacationResponse are subject to the restrictions of [RFC5230] and [RFC3834], which mitigate these risks, and servers SHOULD NOT send automatic replies to messages they classify as spam (Section 8). The reject action is defined in terms of "ereject", which refuses messages during the SMTP or LMTP transaction where possible (Section 2.1 of [RFC5429]). When that is not possible, for example because the reason contains non-ASCII characters or because the message was already accepted, a delivery status notification is sent to the envelope sender, which can cause backscatter.

Automatic replies also disclose to the sender that the address is valid and actively read, and may disclose information such as the user's absence. Clients SHOULD make users aware of this when configuring replies.

12.4. Forged Header Fields

Most conditions test header fields that are set by the sender and can be forged. Rules are therefore not suitable for making security decisions. In particular, a forged "From" header field could cause a message to bypass spam filtering if the safe list were applied without authentication, which is why Section 7.2 requires authentication. A forged "From" header field can also cause a legitimate message to be filed as spam when it matches the blocked list; the impact of this is limited, since the message remains available in the mailbox with the "junk" role.

Rules can also test header fields that report authentication results, such as "Authentication-Results". Such rules are reliable only if the server removes or renames instances of these header fields that claim to originate from the server itself, as described in Section 5 of [RFC8601].

12.5. Rules Without Conditions

A rule whose condition lists are all empty matches every message. Combined with the discard, reject or redirect actions, such a rule can cause the loss or disclosure of all incoming mail. Clients SHOULD ask the user for confirmation before saving such a rule.

12.6. Header Modification

The setImportance action modifies the header of the message, which can invalidate DKIM signatures (Section 9 of [RFC5293]). This matters mainly for messages that are subsequently forwarded.

12.7. Resource Exhaustion

Rules are evaluated for every incoming message, and wildcard patterns, body tests and large numbers of rules and values can be expensive to evaluate. Servers SHOULD enforce the limits advertised in the capability object, and SHOULD apply the same resource limits that they apply to Sieve scripts.

13. Privacy Considerations

The rule set and the sender lists reveal information about the user's correspondents, interests and habits. A server MUST NOT include the "urn:ietf:params:jmap:mailrules" capability in the "accountCapabilities" of an account for a user who is not authorized to manage its rules; such authorization is a matter of local policy, and is not granted merely by access to the account's mailboxes.

A user who is authorized to manage the rules of another user's account can create a forwarding rule that discloses all future mail of that account. Servers SHOULD restrict this authorization accordingly. Records of rule changes kept for auditing (Section 12.2) are themselves personal data. If the translation of the rule set is made available for inspection (Section 8.2), access to it MUST NOT be broader than access to the MailRule objects.

14. IANA Considerations

14.1. JMAP Capability Registration for "mailrules"

IANA will register the "mailrules" JMAP Capability in the "JMAP Capabilities" registry (Section 9.4 of [RFC8620]) as follows:

Capability Name: urn:ietf:params:jmap:mailrules
Specification document: this document
Intended use: common
Change Controller: IETF
Security and privacy considerations: this document, Section 12 and Section 13

14.2. JMAP Data Type Registrations

IANA will register the "MailRule", "SafeSender" and "BlockedSender" types in the "JMAP Data Types" registry (Section 6.3 of [RFC9404]) as follows:

Type Name: MailRule
Can Reference Blobs: No
Can Use for State Change: Yes
Capability: urn:ietf:params:jmap:mailrules
Reference: this document

Type Name: SafeSender
Can Reference Blobs: No
Can Use for State Change: Yes
Capability: urn:ietf:params:jmap:mailrules
Reference: this document

Type Name: BlockedSender
Can Reference Blobs: No
Can Use for State Change: Yes
Capability: urn:ietf:params:jmap:mailrules
Reference: this document

14.3. Creation of the "JMAP Mail Rules" Registry Group

IANA is requested to create a new registry group, "JMAP Mail Rules", containing the two registries defined below. New registrations in both registries use the Specification Required policy (Section 4.6 of [RFC8126]). The change controller of the initial entries is the IETF.

In addition to the general criteria for Specification Required, the designated expert is expected to verify that:

  • the name follows the naming conventions of the registry, does not contain a colon, and does not differ only in case from an existing registration;

  • the specification defines the properties and semantics of the condition or action, and a complete Sieve equivalent that uses only the base Sieve language and Sieve extensions registered in the "Sieve Extensions" registry;

  • for actions, the execution order is unique within the registry and places the action correctly relative to the existing actions, taking into account the interactions between Sieve actions.

Registrations may have an Intended Use of "common" or "obsolete". Registrations MUST NOT be deleted; a registration that is no longer appropriate for use is marked "obsolete".

Notice of a potential new registration SHOULD be sent to the JMAP mailing list jmap@ietf.org for review, with a copy to the EXTRA mailing list extra@ietf.org when the Sieve equivalent uses Sieve extensions that are not referenced by this document.

New actions SHOULD be registered with an execution order that leaves gaps for future registrations. If an action needs to execute between two actions with consecutive execution orders, the registration has to explain how its position relative to them is determined, and the designated expert verifies that the result is unambiguous.

14.3.1. JMAP Mail Rule Condition Types Registry

The registration template for this registry is:

Type Name:

The value of the @type property of the condition, in upper camel case.

Description:

A brief description of the condition.

Sieve Capabilities:

The Sieve capabilities required by the Sieve equivalent of the condition, or "none".

Intended Use:

"common" or "obsolete".

Reference:

The specification that defines the condition.

Change Controller:

Who may request changes to this entry.

The initial contents of the registry are:

Table 2: Initial Contents of the JMAP Mail Rule Condition Types Registry
Type Name Description Sieve Capabilities Reference
From Addresses in From none Section 5.1.1
To Addresses in To none Section 5.1.1
Cc Addresses in Cc none Section 5.1.1
ToOrCc Addresses in To or Cc none Section 5.1.1
SentToMe User's addresses in To or Cc relational, comparator-i;ascii-numeric Section 5.1.2
RecipientAddress Envelope recipient envelope Section 5.1.3
RecipientDetail Detail of envelope recipient envelope, subaddress Section 5.1.4
Subject Subject text none Section 5.2.1
Body Body text body Section 5.2.2
SubjectOrBody Subject or body text body Section 5.2.3
Header Header field value none Section 5.2.4
HeaderExists Header field presence none Section 5.2.5
HasAttachment Presence of attachments mime Section 5.2.6
AttachmentName Attachment file names mime Section 5.2.7
AttachmentType Body part media types mime Section 5.2.8
SizeOver Message larger than a size none Section 5.2.9
SizeUnder Message smaller than a size none Section 5.2.9
Importance Message importance none Section 5.3.1
Sensitivity Message sensitivity none Section 5.3.2
MessageType Kind of message mime Section 5.3.3
MailingList Mailing list message none Section 5.3.4
SpamScore Spam score spamtestplus, relational, comparator-i;ascii-numeric Section 5.3.5
Keyword Keywords set by earlier actions imap4flags Section 5.4.1
AnyKeyword Any keyword set by earlier actions imap4flags Section 5.4.2
ReceivedAfter Processed at or after a date date, relational Section 5.5.1
ReceivedBefore Processed before a date date, relational Section 5.5.1
Schedule Processed within weekly time slots date, relational Section 5.5.2
IsAway VacationResponse in effect date, relational Section 5.5.3

All initial entries have an Intended Use of "common" and a Change Controller of "IETF".

14.3.2. JMAP Mail Rule Actions Registry

The registration template for this registry is:

Action Name:

The name of the property of the RuleActions object, in lower camel case.

Value Type:

The type of the property value, using the type signatures of Section 1.1 of [RFC8620].

Execution Order:

A positive integer, unique within the registry, that determines the order in which the action is executed relative to other actions (Section 2.4).

Description:

A brief description of the action.

Sieve Capabilities:

The Sieve capabilities required by the Sieve equivalent of the action, or "none".

Intended Use:

"common" or "obsolete".

Reference:

The specification that defines the action.

Change Controller:

Who may request changes to this entry.

The initial contents of the registry are:

Table 3: Initial Contents of the JMAP Mail Rule Actions Registry
Action Name Value Type Order Description Sieve Capabilities
clearKeywords Boolean 100 Remove all keywords imap4flags
removeKeywords String[Boolean] 200 Remove keywords imap4flags
addKeywords String[Boolean] 300 Add keywords imap4flags
setImportance String|null 400 Set importance editheader
redirect Redirect|null 500 Forward message copy, variables
reply Reply|null 600 Send automatic reply vacation, variables, vacation-seconds
copyTo Id[Boolean] 700 File a copy fileinto, copy, variables
moveTo Id[Boolean] 800 File message fileinto, variables
discard Boolean 900 Discard message none
reject Reject|null 1000 Refuse message ereject, variables
stopProcessing Boolean 1100 Stop evaluation none

The Reference of each entry is this document, in the section that defines the action (Section 6).

All initial entries have an Intended Use of "common" and a Change Controller of "IETF".

The "Sieve Capabilities" column of both registries lists the capabilities that the Sieve equivalent may require; some are needed only for particular property values. The "comparator-i;unicode-casemap" capability, required when a server advertises that comparator (Section 3.1), is not listed.

15. References

15.1. Normative References

[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/rfc/rfc2119>.
[RFC3339]
Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, , <https://www.rfc-editor.org/rfc/rfc3339>.
[RFC3834]
Moore, K., "Recommendations for Automatic Responses to Electronic Mail", RFC 3834, DOI 10.17487/RFC3834, , <https://www.rfc-editor.org/rfc/rfc3834>.
[RFC3894]
Degener, J., "Sieve Extension: Copying Without Side Effects", RFC 3894, DOI 10.17487/RFC3894, , <https://www.rfc-editor.org/rfc/rfc3894>.
[RFC4790]
Newman, C., Duerst, M., and A. Gulbrandsen, "Internet Application Protocol Collation Registry", RFC 4790, DOI 10.17487/RFC4790, , <https://www.rfc-editor.org/rfc/rfc4790>.
[RFC5051]
Crispin, M., "i;unicode-casemap - Simple Unicode Collation Algorithm", RFC 5051, DOI 10.17487/RFC5051, , <https://www.rfc-editor.org/rfc/rfc5051>.
[RFC5173]
Degener, J. and P. Guenther, "Sieve Email Filtering: Body Extension", RFC 5173, DOI 10.17487/RFC5173, , <https://www.rfc-editor.org/rfc/rfc5173>.
[RFC5228]
Guenther, P., Ed. and T. Showalter, Ed., "Sieve: An Email Filtering Language", RFC 5228, DOI 10.17487/RFC5228, , <https://www.rfc-editor.org/rfc/rfc5228>.
[RFC5229]
Homme, K., "Sieve Email Filtering: Variables Extension", RFC 5229, DOI 10.17487/RFC5229, , <https://www.rfc-editor.org/rfc/rfc5229>.
[RFC5230]
Showalter, T. and N. Freed, Ed., "Sieve Email Filtering: Vacation Extension", RFC 5230, DOI 10.17487/RFC5230, , <https://www.rfc-editor.org/rfc/rfc5230>.
[RFC5231]
Segmuller, W. and B. Leiba, "Sieve Email Filtering: Relational Extension", RFC 5231, DOI 10.17487/RFC5231, , <https://www.rfc-editor.org/rfc/rfc5231>.
[RFC5232]
Melnikov, A., "Sieve Email Filtering: Imap4flags Extension", RFC 5232, DOI 10.17487/RFC5232, , <https://www.rfc-editor.org/rfc/rfc5232>.
[RFC5233]
Murchison, K., "Sieve Email Filtering: Subaddress Extension", RFC 5233, DOI 10.17487/RFC5233, , <https://www.rfc-editor.org/rfc/rfc5233>.
[RFC5235]
Daboo, C., "Sieve Email Filtering: Spamtest and Virustest Extensions", RFC 5235, DOI 10.17487/RFC5235, , <https://www.rfc-editor.org/rfc/rfc5235>.
[RFC5260]
Freed, N., "Sieve Email Filtering: Date and Index Extensions", RFC 5260, DOI 10.17487/RFC5260, , <https://www.rfc-editor.org/rfc/rfc5260>.
[RFC5293]
Degener, J. and P. Guenther, "Sieve Email Filtering: Editheader Extension", RFC 5293, DOI 10.17487/RFC5293, , <https://www.rfc-editor.org/rfc/rfc5293>.
[RFC5322]
Resnick, P., Ed., "Internet Message Format", RFC 5322, DOI 10.17487/RFC5322, , <https://www.rfc-editor.org/rfc/rfc5322>.
[RFC5429]
Stone, A., Ed., "Sieve Email Filtering: Reject and Extended Reject Extensions", RFC 5429, DOI 10.17487/RFC5429, , <https://www.rfc-editor.org/rfc/rfc5429>.
[RFC5703]
Hansen, T. and C. Daboo, "Sieve Email Filtering: MIME Part Tests, Iteration, Extraction, Replacement, and Enclosure", RFC 5703, DOI 10.17487/RFC5703, , <https://www.rfc-editor.org/rfc/rfc5703>.
[RFC5804]
Melnikov, A., Ed. and T. Martin, "A Protocol for Remotely Managing Sieve Scripts", RFC 5804, DOI 10.17487/RFC5804, , <https://www.rfc-editor.org/rfc/rfc5804>.
[RFC5890]
Klensin, J., "Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework", RFC 5890, DOI 10.17487/RFC5890, , <https://www.rfc-editor.org/rfc/rfc5890>.
[RFC5891]
Klensin, J., "Internationalized Domain Names in Applications (IDNA): Protocol", RFC 5891, DOI 10.17487/RFC5891, , <https://www.rfc-editor.org/rfc/rfc5891>.
[RFC6131]
George, R. and B. Leiba, "Sieve Vacation Extension: "Seconds" Parameter", RFC 6131, DOI 10.17487/RFC6131, , <https://www.rfc-editor.org/rfc/rfc6131>.
[RFC6609]
Daboo, C. and A. Stone, "Sieve Email Filtering: Include Extension", RFC 6609, DOI 10.17487/RFC6609, , <https://www.rfc-editor.org/rfc/rfc6609>.
[RFC8126]
Cotton, M., Leiba, B., and T. Narten, "Guidelines for Writing an IANA Considerations Section in RFCs", BCP 26, RFC 8126, DOI 10.17487/RFC8126, , <https://www.rfc-editor.org/rfc/rfc8126>.
[RFC8174]
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, , <https://www.rfc-editor.org/rfc/rfc8174>.
[RFC8620]
Jenkins, N. and C. Newman, "The JSON Meta Application Protocol (JMAP)", RFC 8620, DOI 10.17487/RFC8620, , <https://www.rfc-editor.org/rfc/rfc8620>.
[RFC8621]
Jenkins, N. and C. Newman, "The JSON Meta Application Protocol (JMAP) for Mail", RFC 8621, DOI 10.17487/RFC8621, , <https://www.rfc-editor.org/rfc/rfc8621>.
[RFC9661]
Murchison, K., "The JSON Meta Application Protocol (JMAP) for Sieve Scripts", RFC 9661, DOI 10.17487/RFC9661, , <https://www.rfc-editor.org/rfc/rfc9661>.

15.2. Informative References

[RFC1847]
Galvin, J., Murphy, S., Crocker, S., and N. Freed, "Security Multiparts for MIME: Multipart/Signed and Multipart/Encrypted", RFC 1847, DOI 10.17487/RFC1847, , <https://www.rfc-editor.org/rfc/rfc1847>.
[RFC2047]
Moore, K., "MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text", RFC 2047, DOI 10.17487/RFC2047, , <https://www.rfc-editor.org/rfc/rfc2047>.
[RFC2156]
Kille, S., "MIXER (Mime Internet X.400 Enhanced Relay): Mapping between X.400 and RFC 822/MIME", RFC 2156, DOI 10.17487/RFC2156, , <https://www.rfc-editor.org/rfc/rfc2156>.
[RFC2369]
Neufeld, G. and J. Baer, "The Use of URLs as Meta-Syntax for Core Mail List Commands and their Transport through Message Header Fields", RFC 2369, DOI 10.17487/RFC2369, , <https://www.rfc-editor.org/rfc/rfc2369>.
[RFC2919]
Chandhok, R. and G. Wenger, "List-Id: A Structured Field and Namespace for the Identification of Mailing Lists", RFC 2919, DOI 10.17487/RFC2919, , <https://www.rfc-editor.org/rfc/rfc2919>.
[RFC3464]
Moore, K. and G. Vaudreuil, "An Extensible Message Format for Delivery Status Notifications", RFC 3464, DOI 10.17487/RFC3464, , <https://www.rfc-editor.org/rfc/rfc3464>.
[RFC4021]
Klyne, G. and J. Palme, "Registration of Mail and MIME Header Fields", RFC 4021, DOI 10.17487/RFC4021, , <https://www.rfc-editor.org/rfc/rfc4021>.
[RFC5183]
Freed, N., "Sieve Email Filtering: Environment Extension", RFC 5183, DOI 10.17487/RFC5183, , <https://www.rfc-editor.org/rfc/rfc5183>.
[RFC5546]
Daboo, C., Ed., "iCalendar Transport-Independent Interoperability Protocol (iTIP)", RFC 5546, DOI 10.17487/RFC5546, , <https://www.rfc-editor.org/rfc/rfc5546>.
[RFC6047]
Melnikov, A., Ed., "iCalendar Message-Based Interoperability Protocol (iMIP)", RFC 6047, DOI 10.17487/RFC6047, , <https://www.rfc-editor.org/rfc/rfc6047>.
[RFC6531]
Yao, J. and W. Mao, "SMTP Extension for Internationalized Email", RFC 6531, DOI 10.17487/RFC6531, , <https://www.rfc-editor.org/rfc/rfc6531>.
[RFC6557]
Lear, E. and P. Eggert, "Procedures for Maintaining the Time Zone Database", BCP 175, RFC 6557, DOI 10.17487/RFC6557, , <https://www.rfc-editor.org/rfc/rfc6557>.
[RFC8098]
Hansen, T., Ed. and A. Melnikov, Ed., "Message Disposition Notification", STD 85, RFC 8098, DOI 10.17487/RFC8098, , <https://www.rfc-editor.org/rfc/rfc8098>.
[RFC8551]
Schaad, J., Ramsdell, B., and S. Turner, "Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 4.0 Message Specification", RFC 8551, DOI 10.17487/RFC8551, , <https://www.rfc-editor.org/rfc/rfc8551>.
[RFC8579]
Bosch, S., "Sieve Email Filtering: Delivering to Special-Use Mailboxes", RFC 8579, DOI 10.17487/RFC8579, , <https://www.rfc-editor.org/rfc/rfc8579>.
[RFC8601]
Kucherawy, M., "Message Header Field for Indicating Message Authentication Status", RFC 8601, DOI 10.17487/RFC8601, , <https://www.rfc-editor.org/rfc/rfc8601>.
[RFC8984]
Jenkins, N. and R. Stepanek, "JSCalendar: A JSON Representation of Calendar Data", RFC 8984, DOI 10.17487/RFC8984, , <https://www.rfc-editor.org/rfc/rfc8984>.
[RFC9042]
Gondwana, B., Ed., "Sieve Email Filtering: Delivery by MAILBOXID", RFC 9042, DOI 10.17487/RFC9042, , <https://www.rfc-editor.org/rfc/rfc9042>.
[RFC9404]
Gondwana, B., Ed., "JSON Meta Application Protocol (JMAP) Blob Management Extension", RFC 9404, DOI 10.17487/RFC9404, , <https://www.rfc-editor.org/rfc/rfc9404>.
[RFC9989]
Herr, T., Ed. and J. Levine, Ed., "Domain-Based Message Authentication, Reporting, and Conformance (DMARC)", RFC 9989, DOI 10.17487/RFC9989, , <https://www.rfc-editor.org/rfc/rfc9989>.
[TZDB]
IANA, "Time Zone Database", n.d., <https://www.iana.org/time-zones>.

Appendix A. Changes

[[This section to be removed by RFC Editor]]

draft-degennaro-jmap-mail-rules-00

Authors' Addresses

Mauro De Gennaro
Stalwart Labs LLC
10080 N Wolfe Road, Suite SW3-200
Cupertino, CA 95014
United States of America
Hans-Joerg Happel
audriga