| RFC 9042 | Sieve MAILBOXID | June 2021 |
| Gondwana | Standards Track | [Page] |
The OBJECTID capability of IMAP (RFC 8474) allows clients toidentify mailboxes by a unique identifier that survives renaming.¶
This document extends the Sieve email filtering language (RFC 5228) toallow using that same unique identifier as a target for fileinto rulesand for testing the existence of mailboxes.¶
This is an Internet Standards Track document.¶
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.¶
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained athttps://www.rfc-editor.org/info/rfc9042.¶
Copyright (c) 2021 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.¶
Sieve rules[RFC5228] are sometimes created using graphical interfaces,which allow users to select the mailbox to be used as a target for a rule.¶
If that mailbox is renamed, the client may also update its internalrepresentation of the rule and update the Sieve script to match;however, this is a multistep process and subject to partial failures.Also, if the folder is renamed by a different mechanism (e.g., anotherIMAP client), the rules will get out of sync.¶
By telling fileinto to reference the immutable MAILBOXID specifiedby[RFC8474], using the extension specified herein, Sieve rules cancontinue to target the same mailbox, even if it gets renamed.¶
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.¶
Scripts that use the extensions defined in this documentMUST explicitly requirethe capability "mailboxid".¶
Example:¶
require "mailboxid";¶
Normally, the fileinto command delivers the message in the mailboxspecified using its positional mailbox argument. However, if theoptional :mailboxid argument is also specified, the fileintocommand first checks whether a mailbox exists in the user's personalnamespace[RFC2342] with the specified MAILBOXID[RFC8474].¶
If a matching mailbox is found, that mailbox is used for delivery.¶
If there is no such mailbox, the fileinto action proceeds as it wouldwithout the :mailboxid argument.¶
The tagged argument :mailboxid to fileinto consumes one additional token,a string containing the OBJECTID of the target mailbox.¶
Example:¶
require "fileinto";require "mailboxid";if header :contains ["from"] "coyote" { fileinto :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3" "INBOX.harassment";}¶For servers that also support the mailbox extension defined in[RFC5490], if both the:create and :mailboxid arguments are provided to a fileinto command andno matching mailbox is found, then a new mailbox will be created.¶
This new mailbox will have the name specified by the positional mailboxargument ([RFC5228],Section 4.1); however, it will get a different MAILBOXID(chosen by the server) rather than the one specified by the :mailboxidargument to fileinto.¶
Example:¶
require "fileinto";require "mailboxid";require "mailbox";fileinto :mailboxid "Fnosuch" :create "INBOX.no-such-folder"; # creates INBOX.no-such-folder, but it doesn't # get the "Fnosuch" mailboxid.¶
For servers that also support delivery to special-use mailboxes[RFC8579],it is an error to specify both :mailboxid and :specialuse in the samefileinto command.¶
Advanced filtering based on both special-use and MAILBOXID can bebuilt with explicit specialuse_exists and mailboxidexists tests.¶
Note to developers of Sieve generation tools:¶
It is advisable to usespecial-use rather than MAILBOXID when creating rules that are basedon a special-use purpose (e.g., delivery directly to the Junk folderbased on a header that was added by a scanning agent earlier in themail flow).¶
This document extends the definition of the :fcc argument defined in[RFC8580] so that it can optionally be used with the :mailboxidargument. The syntax for FCC is extended here using ABNF[RFC5234]:¶
MAILBOXID-OPT = ":mailboxid" objectidFCC-OPTS =/ MAILBOXID-OPT¶
If the optional :mailboxid argument is specified with :fcc, itinstructs the Sieve interpreter to check whether a mailbox existswith the specific MAILBOXID. If such a mailbox exists, the generatedmessage is filed into that mailbox. Otherwise, the generated messageis filed into the :fcc target mailbox.¶
As with fileinto, it is an error to specify both :mailboxidand :specialuse for the same fcc rule.¶
Example:¶
require ["enotify", "fcc", "mailboxid"];notify :fcc "INBOX.Sent" :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3" :message "You got mail!" "mailto:ken@example.com";¶
Usage: mailboxidexists <mailbox-objectids: string-list>¶
The mailboxidexists test is true if every string argument provided is the MAILBOXID of a mailbox that exists in the mailstore and that allows the user in whose context the Sieve script runs to deliver messages into it.¶
When the mailstore is an IMAP server that also supports IMAPAccess Control List (ACL)[RFC4314], delivery is allowed if the user has the 'p' or 'i' rights for the mailbox (seeSection 5.2 of [RFC4314]).¶
When the mailstore is an IMAP server that does not support IMAP ACL, delivery is allowed if the READ-WRITE response code is present for the mailbox when selected by the user (seeSection 7.1 of [RFC3501]).¶
Note that a successful mailboxidexists test for a mailbox doesn'tnecessarily mean that a "fileinto :mailboxid" action on this mailboxwould succeed. For example, the fileinto action might put the user overquota. The mailboxidexists test only verifies existence of themailbox and whether the user in whose context the Sieve script runshas permissions to execute fileinto on it.¶
Example:¶
require "fileinto";require "mailboxid";if header :contains ["from"] "coyote" { if mailboxidexists "F6352ae03-b7f5-463c-896f-d8b48ee3" { fileinto :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3" "INBOX.name.will.not.be.used"; } else { fileinto "INBOX.harassment"; }}¶Note to implementers:¶
This test behaves identically to themailboxexists test defined in[RFC5490] but operates onMAILBOXIDs rather than mailbox names.¶
There is no special interaction defined; however, as an OBJECTIDis a string in this document, OBJECTID values can containvariable expansions if[RFC5229] is enabled.¶
Because MAILBOXID is always generated by the server, implementationsMUST NOT allow Sieve to make an end run around this protection bycreating mailboxes with the specified ID by using :create and:mailboxid in a fileinto rule for a nonexistent mailbox.¶
Implementers are referred to the Security Considerations sectionsof[RFC5228] and[RFC8474].¶
IANA has added the following capability to the "Sieve Extensions" registryat<https://www.iana.org/assignments/sieve-extensions>:¶
This document borrows heavily from[RFC5490] for the matchingmailboxexists test and from[RFC8579] for an example of modifyingthe fileinto command.¶
Thanks toNed Freed,Ken Murchison, andAlexey Melnikov for feedbackon the EXTRA mailing list.¶