Sieve Email Filtering: Delivery by MAILBOXID
updates
- rfc-5228 — Sieve: An Email Filtering Language
Extracted elements (17)
Sieve rules created via graphical interfaces reference mailboxes by name; if a mailbox is renamed by another IMAP client, those rules go out of sync. By referencing the immutable MAILBOXID (RFC 8474) instead of the mailbox name, Sieve rules continue to target the correct mailbox even after renaming.
The note to developers of Sieve generation tools advises using :specialuse rather than :mailboxid when creating rules based on a special-use purpose (e.g., delivering to the Junk folder), because special-use flags better capture intent and are more portable across server configurations.
A successful mailboxidexists test does not guarantee a subsequent fileinto :mailboxid will succeed; for example, the user may be over quota. The test only verifies existence and delivery permission, not that the delivery will complete.
For servers supporting the mailbox extension (RFC 5490), if both :create and :mailboxid are provided and no matching mailbox is found, a new mailbox is created with the name from the positional argument but receives a server-chosen MAILBOXID rather than the one specified in :mailboxid.
The mailboxidexists test behaves identically to the mailboxexists test defined in RFC 5490 but operates on MAILBOXIDs rather than mailbox names.
There is no special interaction between this extension and the Variables Extension (RFC 5229); however, since OBJECTID is a string in this document, OBJECTID values can contain variable expansions if RFC 5229 is enabled.
As with fileinto, it is an error to specify both :mailboxid and :specialuse for the same fcc rule.
If the optional :mailboxid argument is specified and a matching mailbox is found by MAILBOXID in the user's personal namespace, that mailbox is used for delivery. If no such mailbox is found, fileinto proceeds as it would without the :mailboxid argument.
It is an error to specify both :mailboxid and :specialuse in the same fileinto command. Advanced filtering combining both criteria must use explicit mailboxidexists and specialuse_exists tests.
Scripts that use the extensions defined in this document MUST explicitly require the capability "mailboxid".
When the mailstore is an IMAP server supporting ACL (RFC 4314), delivery is considered allowed for mailboxidexists if the user has the 'p' or 'i' rights for the mailbox.
When the mailstore is an IMAP server that does not support IMAP ACL, delivery is allowed for mailboxidexists if the READ-WRITE response code is present for the mailbox when selected by the user (RFC 3501 Section 7.1).
The :fcc argument (RFC 8580) is extended to accept an optional :mailboxid argument. ABNF: MAILBOXID-OPT = ":mailboxid" objectid; FCC-OPTS =/ MAILBOXID-OPT. When specified, the Sieve interpreter checks for a mailbox with the given MAILBOXID and files there if found; otherwise falls back to the :fcc target mailbox.
The :mailboxid tagged argument to fileinto consumes one additional token — a string containing the OBJECTID of the target mailbox. When specified, fileinto first checks whether a mailbox exists in the user's personal namespace with that MAILBOXID and, if found, delivers there; otherwise proceeds as without :mailboxid.
The mailboxidexists test takes a string-list of mailbox OBJECTIDs and returns true if every provided MAILBOXID corresponds to a mailbox that exists in the mailstore and allows the script-running user to deliver messages into it.
IANA has added the "mailboxid" capability to the "Sieve Extensions" registry. It adds a test for checking mailbox existence by OBJECTID and new optional :mailboxid arguments to fileinto and :fcc for selecting the destination mailbox by OBJECTID.
Because MAILBOXID is always generated by the server, implementations MUST NOT allow Sieve to circumvent this protection by creating mailboxes with a specified MAILBOXID via :create and :mailboxid for a nonexistent mailbox. Implementations are also referred to the Security Considerations of RFC 5228 and RFC 8474.