EXTRA

Internet Engineering Task Force (IETF)                  B. Gondwana, Ed.
Internet-Draft
Request for Comments: 9042                                      Fastmail
Updates: 5228 (if approved)                                16 March                                                  June 2021
Intended status:
Category: Standards Track
Expires: 17 September 2021
ISSN: 2070-1721

              Sieve Email Filtering: delivery Delivery by mailboxid
                  draft-ietf-extra-sieve-mailboxid-09 MAILBOXID

Abstract

   The OBJECTID capability of the IMAP protocol (RFC8474) (RFC 8474) allows clients to identify
   mailboxes by a unique identifier which that survives rename. renaming.

   This document extends the Sieve mail email filtering language (RFC5228) (RFC 5228)
   to allow using that same unique identifier as a target for fileinto
   rules,
   rules and for testing the existance existence of mailboxes.

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 an Internet Standards Track document.

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

   Internet-Drafts are draft documents valid the IETF community.  It has
   received public review and has been approved for a maximum publication by the
   Internet Engineering Steering Group (IESG).  Further information on
   Internet Standards is available in Section 2 of six months RFC 7841.

   Information about the current status of this document, any errata,
   and how to provide feedback on it may be updated, replaced, or obsoleted by other documents obtained 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 17 September 2021.
   https://www.rfc-editor.org/info/rfc9042.

Copyright Notice

   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)
   (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.

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
   2.  Conventions Used In in This Document . . . . . . . . . . . . . .   3
   3.  Sieve capability string . . . . . . . . . . . . . . . . . . .   3 Capability String
   4.  Argument ":mailboxid" :mailboxid to Command "fileinto" . . . . . . . . .   3 fileinto
     4.1.  Interaction with "mailbox" extension  . . . . . . . . . .   4 Mailbox Extension
     4.2.  Interaction with "specialuse" extension . . . . . . . . .   4 Special-Use Extension
   5.  Interaction with "fcc" extension  . . . . . . . . . . . . . .   5 FCC Extension
   6.  Test "mailboxidexists"  . . . . . . . . . . . . . . . . . . .   5 mailboxidexists
   7.  Interaction with variables extension  . . . . . . . . . . . .   6 Variables Extension
   8.  Security considerations . . . . . . . . . . . . . . . . . . .   6 Considerations
   9.  IANA considerations . . . . . . . . . . . . . . . . . . . . .   6 Considerations
   10. Acknowledgements  . . . . . . . . . . . . . . . . . . . . . .   7
   11. Changes . . . . . . . . . . . . . . . . . . . . . . . . . . .   7
     11.1.  draft-ietf-sieve-mailboxid-09  . . . . . . . . . . . . .   7
     11.2.  draft-ietf-sieve-mailboxid-08  . . . . . . . . . . . . .   7
     11.3.  draft-ietf-sieve-mailboxid-07  . . . . . . . . . . . . .   7
     11.4.  draft-ietf-sieve-mailboxid-06  . . . . . . . . . . . . .   8
     11.5.  draft-ietf-sieve-mailboxid-05  . . . . . . . . . . . . .   8
     11.6.  draft-ietf-sieve-mailboxid-04  . . . . . . . . . . . . .   8
     11.7.  draft-ietf-sieve-mailboxid-03  . . . . . . . . . . . . .   8
     11.8.  draft-ietf-sieve-mailboxid-02  . . . . . . . . . . . . .   8
     11.9.  draft-ietf-sieve-mailboxid-01  . . . . . . . . . . . . .   8
     11.10. draft-ietf-sieve-mailboxid-00  . . . . . . . . . . . . .   8
     11.11. draft-gondwana-sieve-mailboxid-02  . . . . . . . . . . .   9
     11.12. draft-gondwana-sieve-mailboxid-01  . . . . . . . . . . .   9
     11.13. draft-gondwana-sieve-mailboxid-00  . . . . . . . . . . .   9
   12. References
     10.1.  Normative References  . . . . . . . . . . . . . . . . . . . .   9
   13.
     10.2.  Informative References  . . . . . . . . . . . . . . . . . . .  10
   Acknowledgements
   Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .  10

1.  Introduction

   [RFC5228]

   Sieve rules [RFC5228] are sometimes created using graphical
   interfaces
   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 internal
   representation of the rule and update the sieve Sieve script to match,
   however match;
   however, this is a multi-step multistep process and subject to partial failures.
   Also, if the folder is renamed by a different mechanism (e.g. (e.g.,
   another IMAP client) client), the rules will get out of sync.

   By telling "fileinto" fileinto to reference the immutable mailboxid MAILBOXID specified by
   [RFC8474], using the extension specified herein, sieve Sieve rules can
   continue to target the same mailbox mailbox, even if it gets renamed.

2.  Conventions Used In in This Document

   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.

3.  Sieve capability string Capability String

   Scripts which that use the following extensions defined in this document MUST
   explicitly require the capability "mailboxid".

   Example:

   require "mailboxid";

4.  Argument ":mailboxid" :mailboxid to Command "fileinto" fileinto

   Normally, the "fileinto" fileinto command delivers the message in the mailbox
   specified using its positional mailbox argument.  However, if the
   optional ":mailboxid" :mailboxid argument is also specified, the "fileinto" fileinto command
   first checks whether a mailbox exists in the user's personal
   namespace [RFC2342] with the specified [RFC8474] MAILBOXID. MAILBOXID [RFC8474].

   If a matching mailbox is found, that mailbox is used for delivery.

   If there is no such mailbox, the "fileinto" fileinto action proceeds as it would
   without the ":mailboxid" :mailboxid argument.

   The tagged argument ":mailboxid" :mailboxid to fileinto consumes one additional
   token, a string with containing the objectid OBJECTID of the mailbox to file into. target mailbox.

   Example:

   require "fileinto";
   require "mailboxid";

   if header :contains ["from"] "coyote" {
       fileinto :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3"
                "INBOX.harassment";
   }

4.1.  Interaction with "mailbox" extension Mailbox Extension

   For servers which that also support the [RFC5490] mailbox extension, extension defined in
   [RFC5490], if both the ":create" :create and ":mailboxid" :mailboxid arguments are provided
   to a
   "fileinto" fileinto command and no matching mailbox is found, then a new
   mailbox will be created.

   This new mailbox will have the name specified by the positional
   mailbox argument ([RFC5228] section 4.1), however ([RFC5228], Section 4.1); however, it will get a
   different mailboxid MAILBOXID (chosen by the server) rather than the one
   specified by the ":mailboxid" :mailboxid argument 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.

4.2.  Interaction with "specialuse" extension Special-Use Extension

   For servers which that also support [RFC8579] delivery to special-use
   mailboxes, mailboxes
   [RFC8579], it is an error to specify both ":mailboxid" :mailboxid and
   ":specialuse" :specialuse
   in the same fileinto command.

   Advanced filtering based on both special-use and mailboxid MAILBOXID can be
   built with explicit "specialuse_exists" specialuse_exists and "mailboxidexists" mailboxidexists tests.

      |  Note to developers of sieve Sieve generation tools: it
      |
      |  It is advisable to use special-use rather than mailboxid MAILBOXID when
      |  creating rules that are based on a special-use purpose (e.g. (e.g.,
      |  delivery directly to the Junk folder based on a header that was
      |  added by a scanning agent earlier in the
   mailflow). mail flow).

5.  Interaction with "fcc" extension FCC Extension

   This document extends the definition of the ":fcc" :fcc argument defined in
   [RFC8580] so that it can optionally be used with the ":mailboxid" :mailboxid
   argument.  The syntax for "FCC" FCC is extended here using ABNF [RFC5234]:

   MAILBOXID-OPT = ":mailboxid" objectid

   FCC-OPTS =/ MAILBOXID-OPT

   If the optional ":mailboxid" :mailboxid argument is specified with ":fcc", :fcc, it
   instructs the Sieve interpreter to check whether a mailbox exists
   with the specific mailboxid. MAILBOXID.  If such a mailbox exists, the generated
   message is filed into that mailbox.  Otherwise, the generated message
   is filed into the ":fcc" :fcc target mailbox.

   As with fileinto, it is an error to specify both ":mailboxid" :mailboxid and
   ":specialuse"
   :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";

6.  Test "mailboxidexists" mailboxidexists

   Usage: mailboxidexists <mailbox-objectids: string-list>

   The "mailboxidexists" mailboxidexists test is true if all mailboxes listed in the
   "mailboxids" every string argument exist provided is
   the MAILBOXID of a mailbox that exists in the mailstore, mailstore and each that
   allows the user in whose context the Sieve script runs to "deliver" deliver
   messages into it.

   When the mailstore is an IMAP server, "delivery" of
   messages server that also supports IMAP Access
   Control List (ACL) [RFC4314], delivery is possible if:

   a) allowed if the READ-WRITE response code is present user has the
   'p' or 'i' rights for the mailbox (see Section 7.1 5.2 of [RFC3501]), if IMAP Access Control List (ACL)
   [RFC4314] [RFC4314]).

   When the mailstore is an IMAP server that does not supported by the server, or

   b) support IMAP ACL,
   delivery is allowed if the user has 'p' or 'i' rights READ-WRITE response code is present for
   the mailbox when selected by the user (see Section 5.2 7.1 of
   [RFC4314]). [RFC3501]).

   Note that a successful "mailboxidexists" mailboxidexists test for a mailbox doesn't
   necessarily mean that a "fileinto :mailboxid" action on this mailbox
   would succeed.  For example, the "fileinto" fileinto action might put the user
   over quota.  The "mailboxidexists" mailboxidexists test only verifies existence of the
   mailbox and whether the user in whose context the Sieve script runs
   has permissions to execute "fileinto" 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
      |
      |  This test behaves identically to the
   "mailboxexists" mailboxexists test defined
      |  in [RFC5490] but operates on mailboxids MAILBOXIDs rather than mailbox
      |  names.

7.  Interaction with variables extension Variables Extension

   There is no special interaction defined, however defined; however, as an objectid OBJECTID is a
   string in this document, objectid OBJECTID values can contain variable
   expansions if [RFC5229] is enabled.

8.  Security considerations Considerations

   Because mailboxid MAILBOXID is always generated by the server, implementations
   MUST NOT allow sieve Sieve to make an endrun end run around this protection by
   creating mailboxes with the specified ID by using ":create" :create and
   ":mailboxid"
   :mailboxid in a fileinto rule for a non-existant nonexistent mailbox.

   Implementers are referred to the security considerations Security Considerations sections of
   [RFC5228] and [RFC8474].

9.  IANA considerations Considerations

   IANA are requested to add a has added the following capability to the sieve-extensions
   registry:

   To: iana@iana.org
   Subject: Registration of new Sieve extension "Sieve Extensions"
   registry at <https://www.iana.org/assignments/sieve-extensions>:

   Capability name:  mailboxid
   Description:  adds a test for checking mailbox existence by objectid, OBJECTID
      and new optional arguments to fileinto and :fcc which that allow
      selecting the destination mailbox by objectid. OBJECTID.
   RFC number: this  RFC 9042
   Contact address: The  EXTRA discussion list <extra@ietf.org>

10.  Acknowledgements

   This document borrows heavily from [RFC5490] for the matching
   mailboxexists test, and from [RFC8579] for an example of modifying
   the fileinto command.

   Thanks to Ned Freed and Ken Murchison and Alexey Melnikov for
   feedback on the EXTRA mailing list.

11.  Changes

   (EDITOR: remove this section before publication)

11.1.  draft-ietf-sieve-mailboxid-09

   *  update FCC-OPTS to have an intermediate production for the
      :mailboxid option, and reference "objectid" from RFC8474 as the
      valid format for the option value.

11.2.  draft-ietf-sieve-mailboxid-08

   *  IETF110 discussion - re-add FCC-OPTS syntax, and clarify that
      :mailboxid is incompatible with :specialuse to parallel the
      fileinto behaviour

11.3.  draft-ietf-sieve-mailboxid-07

   *  Martin Duke review - remove formal section

   *  Martin Duke review - wording  References

10.1.  Normative References

   [RFC2119]  Bradner, S., "Key words for section 4.1 (interaction with
      :create)

   *  Ken Murchison review - fixed :special-use to :specialuse per
      RFC8579

11.4.  draft-ietf-sieve-mailboxid-06

   *  GENART review - fixed example to not be semantically pointless

   *  GENART review - fixed !@ to @! in RFC reference mmark syntax

11.5.  draft-ietf-sieve-mailboxid-05

   *  disallow :mailboxid and :special-use in the same fileinto action.

11.6.  draft-ietf-sieve-mailboxid-04

   *  made RFC5490 and RFC8579 normative

   *  clarified wording based on AD feedback from Barry

11.7.  draft-ietf-sieve-mailboxid-03

   *  Fixed ABNF syntax error

11.8.  draft-ietf-sieve-mailboxid-02

   *  removed bogus : from "mailboxidexists" test title

   *  moved FCC to its own top-level section since it is not used with
      the fileinto command.

11.9.  draft-ietf-sieve-mailboxid-01

   *  fixed idnits - RFC5228 not mentioned use in the abstract

   *  fixed other I-D references I had missed, oops

11.10.  draft-ietf-sieve-mailboxid-00

   *  Adopted into working group per adoption call on list

   *  Updated references to old drafts which have since been published.

   *  Fixed some typoes and simplified some language.

   *  Removed stray leading colon on mailboxexists (thanks Alexey)

   *  Added :fcc to the IANA registration description (thanks Alexey)

   *  Mentioned that variables can be expanded (thanks Alexey)

11.11.  draft-gondwana-sieve-mailboxid-02

   *  Update document date by a couple of years!  Ooops, it got
      forgotten after a WGLC which got not dissent.

   *  Create xml2rfc v3 output.

11.12.  draft-gondwana-sieve-mailboxid-01

   *  Switch RFCs to :mailboxid tagged parameter value with fallback mailbox
      name.

   *  Document interaction with "mailbox".

   *  Document interaction with "special-use".

   *  Document interaction with "fcc".

   *  Document security considerations around :mailboxid Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <https://www.rfc-editor.org/info/rfc2119>.

   [RFC2342]  Gahrns, M. and :create.

11.13.  draft-gondwana-sieve-mailboxid-00

   *  Initial version.

12.  Normative References C. Newman, "IMAP4 Namespace", RFC 2342,
              DOI 10.17487/RFC2342, May 1998,
              <https://www.rfc-editor.org/info/rfc2342>.

   [RFC5228]  Guenther, P., Ed. and T. Showalter, Ed., "Sieve: An Email
              Filtering Language", RFC 5228, DOI 10.17487/RFC5228,
              January 2008, <https://www.rfc-editor.org/info/rfc5228>.

   [RFC8474]  Gondwana, B., Ed., "IMAP Extension for Object
              Identifiers", RFC 8474, DOI 10.17487/RFC8474, September
              2018, <https://www.rfc-editor.org/info/rfc8474>.

   [RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
              2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
              May 2017, <https://www.rfc-editor.org/info/rfc8174>.

   [RFC5234]  Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
              Specifications: ABNF", STD 68, RFC 5234,
              DOI 10.17487/RFC5234, January 2008,
              <https://www.rfc-editor.org/info/rfc5234>.

   [RFC2119]  Bradner, S., "Key words for use

   [RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFCs to Indicate
              Requirement Levels", RFC
              2119 Key Words", BCP 14, RFC 2119, 8174, DOI 10.17487/RFC2119, March 1997,
              <https://www.rfc-editor.org/info/rfc2119>.

   [RFC2342]  Gahrns, M. and C. Newman, "IMAP4 Namespace", 10.17487/RFC8174,
              May 2017, <https://www.rfc-editor.org/info/rfc8174>.

   [RFC8474]  Gondwana, B., Ed., "IMAP Extension for Object
              Identifiers", RFC 2342, 8474, DOI 10.17487/RFC2342, May 1998,
              <https://www.rfc-editor.org/info/rfc2342>. 10.17487/RFC8474, September
              2018, <https://www.rfc-editor.org/info/rfc8474>.

   [RFC8580]  Murchison, K. and B. Gondwana, "Sieve Extension: File
              Carbon Copy (FCC)", RFC 8580, DOI 10.17487/RFC8580, May
              2019, <https://www.rfc-editor.org/info/rfc8580>.

13.

10.2.  Informative References

   [RFC8579]  Bosch, S., "Sieve Email Filtering: Delivering to Special-
              Use Mailboxes", RFC 8579, DOI 10.17487/RFC8579, May 2019,
              <https://www.rfc-editor.org/info/rfc8579>.

   [RFC5490]  Melnikov, A., "The Sieve Mail-Filtering Language --
              Extensions for Checking Mailbox Status and Accessing
              Mailbox Metadata", RFC 5490, DOI 10.17487/RFC5490, March
              2009, <https://www.rfc-editor.org/info/rfc5490>.

   [RFC3501]  Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION
              4rev1", RFC 3501, DOI 10.17487/RFC3501, March 2003,
              <https://www.rfc-editor.org/info/rfc3501>.

   [RFC4314]  Melnikov, A., "IMAP4 Access Control List (ACL) Extension",
              RFC 4314, DOI 10.17487/RFC4314, December 2005,
              <https://www.rfc-editor.org/info/rfc4314>.

   [RFC5229]  Homme, K., "Sieve Email Filtering: Variables Extension",
              RFC 5229, DOI 10.17487/RFC5229, January 2008,
              <https://www.rfc-editor.org/info/rfc5229>.

   [RFC5490]  Melnikov, A., "The Sieve Mail-Filtering Language --
              Extensions for Checking Mailbox Status and Accessing
              Mailbox Metadata", RFC 5490, DOI 10.17487/RFC5490, March
              2009, <https://www.rfc-editor.org/info/rfc5490>.

   [RFC8579]  Bosch, S., "Sieve Email Filtering: Delivering to Special-
              Use Mailboxes", RFC 8579, DOI 10.17487/RFC8579, May 2019,
              <https://www.rfc-editor.org/info/rfc8579>.

Acknowledgements

   This document borrows heavily from [RFC5490] for the matching
   mailboxexists test and from [RFC8579] for an example of modifying the
   fileinto command.

   Thanks to Ned Freed, Ken Murchison, and Alexey Melnikov for feedback
   on the EXTRA mailing list.

Author's Address

   Bron Gondwana (editor)
   Fastmail
   Level 2, 2
   114 William St
   Melbourne VIC 3000
   Australia

   Email: brong@fastmailteam.com
   URI:   https://www.fastmail.com