<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' []>
<rfc ipr="trust200902" category="std" docName="draft-gondwana-sieve-mailboxid-00" updates="7162">
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc private=""?>
<?rfc topblock="yes"?>
<?rfc comments="no"?>
<front>
<title abbrev="Sieve MAILBOXID">Sieve Email Filtering: delivery by mailboxid</title>

<author role="editor" initials="B." surname="Gondwana" fullname="Bron Gondwana">
<organization>FastMail</organization>
<address>
<postal>
<street>Level 2, 114 William St</street>
<city>Melbourne</city>
<code>VIC 3000</code>
<country>Australia</country>
<region></region>
</postal>
<phone></phone>
<email>brong@fastmailteam.com</email>
<uri>https://www.fastmail.com</uri>
</address>
</author>
<date year="2018" month="August" day="11"/>

<area>Applications</area>
<workgroup>EXTRA</workgroup>
<keyword>IMAP</keyword>
<keyword>email</keyword>


<abstract>
<t>The OBJECTID capability of the IMAP protocol (I-D.ietf-extra-imap-objectid)
allows clients to identify mailboxes by a unique identifier which survives
rename. In contrast, the Sieve mail filtering language (RFC 5228) currently
has no such capability.  This memo defines a Sieve extension that fills
this gap: it adds a method for specifying the unique identifier of a mailbox
as a target for fileinto rules, and a method for testing the existence of
a mailbox by its unique identifier.
</t>
</abstract>


</front>

<middle>

<section anchor="introduction" title="Introduction">
<t>Sieve rules 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 internal
representation of the rule and update the sieve script to match,
however this is a multi-step process and subject to partial failures.
Also, if the folder is renamed by a different mechanism (e.g. another
IMAP client) the rules will get out of sync.
</t>
<t>By extending <spanx style="verb">fileinto</spanx> to reference an immutable mailboxid, sieve rules
can continue to target the same mailbox, regardless of how it gets
renamed.
</t>
</section>

<section anchor="conventions-used-in-this-document" title="Conventions Used In This Document">
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL
NOT&quot;, &quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;,
&quot;MAY&quot;, and &quot;OPTIONAL&quot; in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.
</t>
</section>

<section anchor="capability-argument" title="Capability argument">
<t>The server must advertise the capability &quot;mailboxid&quot;, and scripts which use
the following extensions must explicitly request the capability &quot;mailboxid&quot;.
</t>
<t>Example:
</t>

<figure align="center"><artwork align="center">
require "mailboxid";
</artwork></figure>
</section>

<section anchor="argument-mailboxid-to-command-fileinto" title="Argument &quot;:mailboxid&quot; to Command &quot;fileinto&quot;">
<t>Normally, the positional mailbox argument to a fileinto action delivers
the message in a mailbox with the matching <xref target="RFC3501"/> name.
</t>
<t>This document adds a new tagged argument <spanx style="verb">:mailboxid</spanx>.  If the <spanx style="verb">:mailboxid</spanx>
argument is provided, the positional mailbox argument refers to an
<xref target="I-D.ietf-extra-imap-objectid"/> mailboxid rather than an <xref target="RFC3501"/> name.
</t>
<t>If there is no mailbox with the specified <spanx style="verb">:mailboxid</spanx> then the action
is the same as if there was no named mailbox, and implementations are free
to make the same choices given in <xref target="RFC5228"/> Section 4.1 when the specified
mailbox doesn't exist.
</t>
<t>The tagged argument <spanx style="verb">:mailboxid</spanx> to fileinto consumes zero additional tokens.
</t>
<t>Example:
</t>

<figure align="center"><artwork align="center">
require "fileinto";
require "mailboxid";

if header :contains ["from"] "coyote" {
    fileinto :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3";
}
</artwork></figure>
</section>

<section anchor="test-mailboxidexists" title="Test &quot;:mailboxidexists&quot;">
<t>This test behaves identically to the <spanx style="verb">mailboxexists</spanx> test defined in
<xref target="RFC5490"/> but operates on mailboxids rather than mailbox names.
</t>
<t>Usage: <spanx style="verb">mailboxidexists &lt;mailboxids: string-list&gt;</spanx>
</t>
<t>The &quot;mailboxidexists&quot; test is true if all mailboxes listed in the
&quot;mailboxids&quot; argument exist in the mailstore, and each allows the
user in whose context the Sieve script runs to &quot;deliver&quot; messages
into it.  When the mailstore is an IMAP server, &quot;delivery&quot; of
messages is possible if:
</t>
<t>a) the READ-WRITE response code is present for the mailbox (see
   Section 7.1 of <xref target="RFC3501"/>), if IMAP Access Control List (ACL)
   <xref target="RFC4314"/> is not supported by the server, or
</t>
<t>b) the user has 'p' or 'i' rights for the mailbox (see Section 5.2
   of <xref target="RFC4314"/>).
</t>
<t>Note that a successful &quot;mailboxidexists&quot; test for a mailbox doesn't
necessarily mean that a &quot;fileinto :mailboxid&quot; action on this mailbox
would succeed.  For example, the &quot;fileinto&quot; action might put user over
quota.  The &quot;mailboxidexists&quot; only verifies existence of the mailbox
and whether the user in whose context the Sieve script runs has
permissions to execute &quot;fileinto&quot; on it.
</t>
<t>Example:
</t>

<figure align="center"><artwork align="center">
require "fileinto";
require "mailboxid";

if header :contains ["from"] "coyote" {
    if mailboxidexists "F6352ae03-b7f5-463c-896f-d8b48ee3" {
        fileinto :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3";
    } else {
        fileinto "INBOX.harassment";
    }
}
</artwork></figure>
</section>

<section anchor="formal-syntax" title="Formal Syntax">

<figure align="center"><artwork align="center">
test /= ":mailboxidexists" string-list

tag /= ":mailboxid"
</artwork></figure>
</section>

<section anchor="security-considerations" title="Security considerations">
<t>This document does not add any security considerations beyond those
in <xref target="RFC5228"/>, <xref target="RFC5490"/> and <xref target="I-D.ietf-extra-imap-objectid"/>.
Implementers are referred to the security considerations sections
of those documents.
</t>
</section>

<section anchor="iana-considerations" title="IANA considerations">
<t>IANA are requested to add a capability to the sieve-extensions registry:
</t>

<figure align="center"><artwork align="center">
To: iana@iana.org
Subject: Registration of new Sieve extension

Capability name: mailboxid
Description: adds test for checking for mailbox existence by objectid
             and a new optional argument to fileinto to select the
             destination mailbox using objectid.
RFC number: this RFC
Contact address: The EXTRA discussion list &lt;extra@ietf.org&gt;
</artwork></figure>
</section>

<section anchor="acknowledgements" title="Acknowledgements">
<t>This document borrows heavily from <xref target="RFC5490"/> for the matching
mailboxexists test, and from <xref target="I-D.ietf-extra-sieve-special-use"/>
for an example of modifying the fileinto command.
</t>
</section>

<section anchor="todo" title="TODO">
<t>Is there a more explicit way to update the grammar?  It seems less
fully specified than IMAP.
</t>
</section>

</middle>
<back>
<references title="Normative References">
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-extra-imap-objectid.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.3501.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5228.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5490.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"?>
</references>
<references title="Informative References">
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-extra-sieve-special-use.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.4314.xml"?>
</references>

</back>
</rfc>
