<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-ietf-extra-sieve-mailboxid-00" submissionType="IETF" category="std" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" updates="5228" consensus="true">

<front>
<title abbrev="Sieve MAILBOXID">Sieve Email Filtering: delivery by mailboxid</title><seriesInfo value="draft-ietf-extra-sieve-mailboxid-00" stream="IETF" status="standard" name="Internet-Draft"></seriesInfo>
<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>
</postal><email>brong@fastmailteam.com</email>
<uri>https://www.fastmail.com</uri>
</address></author>
<date year="2020" month="July" day="30"></date>
<area>Applications</area>
<workgroup>EXTRA</workgroup>
<keyword>sieve</keyword>
<keyword>email</keyword>

<abstract>
<t>The OBJECTID capability of the IMAP protocol (RFC8474) allows clients to
identify mailboxes by a unique identifier which survives rename.</t>
<t>This document extends the Sieve mail filtering language (RFC5228) to
allow using that same unique identifier as a target for fileinto rules,
and for testing the existance of mailboxes.</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
<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 <tt>fileinto</tt> to reference an immutable mailboxid, sieve rules
can continue to target the same mailbox, even if it gets renamed.</t>
</section>

<section anchor="conventions-used-in-this-document"><name>Conventions Used In This Document</name>
<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> <xref target="RFC8174"></xref> when, and only when,
they appear in all capitals, as shown here.</t>
</section>

<section anchor="sieve-capability-string"><name>Sieve capability string</name>
<t>The server advertises the capability &quot;mailboxid&quot;, and scripts which use
the following extensions MUST explicitly request the capability &quot;mailboxid&quot;.</t>
<t>Example:</t>

<artwork>require &quot;mailboxid&quot;;
</artwork>
</section>

<section anchor="argument-mailboxid-to-command-fileinto"><name>Argument &quot;:mailboxid&quot; to Command &quot;fileinto&quot;</name>
<t>Normally, the &quot;fileinto&quot; command delivers the message in the mailbox
specified using its positional mailbox argument.  However, if the
optional &quot;:mailboxid&quot; argument is also specified, the &quot;fileinto&quot;
command first checks whether a mailbox exists in the user's personal
namespace <xref target="RFC2342"></xref> with the specified <xref target="RFC8474"></xref> MAILBOXID.</t>
<t>If a matching mailbox is found, that mailbox is used for delivery.</t>
<t>If there is no such mailbox, the &quot;fileinto&quot; action proceeds as it would
without the &quot;:mailboxid&quot; argument.</t>
<t>The tagged argument <tt>:mailboxid</tt> to fileinto consumes one additional token,
a string with the objectid of the mailbox to file into.</t>
<t>Example:</t>

<artwork>require &quot;fileinto&quot;;
require &quot;mailboxid&quot;;

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

<section anchor="interaction-with-mailbox-extension"><name>Interaction with &quot;mailbox&quot; extension</name>
<t>For servers which also support the <xref target="RFC5490"></xref> mailbox extension, the &quot;:create&quot;
modifier to fileinto does not create the mailbox with the specified mailboxid,
however it may be specified and interacts as normal with all other extensions.</t>
<t>Example:</t>

<artwork>require &quot;fileinto&quot;;
require &quot;mailboxid&quot;;
require &quot;mailbox&quot;;

fileinto :mailboxid &quot;Fnosuch&quot;
         :create
         &quot;INBOX.no-such-folder&quot;;
            # creates INBOX.no-such-folder, but it doesn't
            # get the &quot;Fnosuch&quot; mailboxid.
</artwork>
</section>

<section anchor="interaction-with-specialuse-extension"><name>Interaction with &quot;specialuse&quot; extension</name>
<t>For servers which also support <xref target="RFC8579"></xref> delivery to special-use mailboxes,
if a fileinto command has both &quot;:mailboxid&quot; and &quot;:special-use&quot; specified, then
the mailboxid is resolved first.</t>
<t>If a mailbox with the specified mailboxid does not exist, then the process
specified in <xref target="RFC8579"></xref> is followed - which includes processing of <xref target="RFC5490"></xref>
&quot;:create&quot; tags to add the special-use to the created mailbox.</t>
<t>Example:</t>

<artwork>require &quot;fileinto&quot;;
require &quot;mailboxid&quot;;
require &quot;special-use&quot;;
if header :contains [&quot;from&quot;] &quot;coyote&quot; {
    fileinto :mailboxid &quot;F6352ae03-b7f5-463c-896f-d8b48ee3&quot;
             :specialuse &quot;\\Junk&quot;
             &quot;INBOX.harassment&quot;;
}
</artwork>
<t>Example:</t>

<artwork>require &quot;fileinto&quot;;
require &quot;mailboxid&quot;;
require &quot;mailbox&quot;;
require &quot;special-use&quot;;

fileinto :mailboxid &quot;F1234567&quot;
         :specialuse &quot;\\Archive&quot;
         :create
         &quot;INBOX.Archive&quot;;
            # creates INBOX.Archive with use \Archive but
            # with a different mailboxid.
</artwork>
</section>

<section anchor="interaction-with-fcc-extension"><name>Interaction with &quot;fcc&quot; extension</name>
<t>This document extends the definition of the &quot;:fcc&quot; argument defined in
<xref target="RFC8580"></xref> so that it can optionally be used with the &quot;:mailboxid&quot;
argument.</t>

<artwork>FCC =/ [&quot;:mailboxid&quot; &lt;mailboxid: string&gt;]
</artwork>
<t>If the optional &quot;:mailboxid&quot; argument is specified with &quot;:fcc&quot;, it
instructs the Sieve interpreter to check whether a mailbox exists
with the specific mailboxid.  If such a mailbox exists, the generated
message is filed into that mailbox.  Otherwise, the generated message
is filed into the &quot;:fcc&quot; target mailbox.</t>
<t>Example:</t>

<artwork>require [&quot;enotify&quot;, &quot;fcc&quot;, &quot;mailboxid&quot;];
notify :fcc &quot;INBOX.Sent&quot;
       :mailboxid &quot;F6352ae03-b7f5-463c-896f-d8b48ee3&quot;
       :message &quot;You got mail!&quot;
       &quot;mailto:ken@example.com&quot;;
</artwork>
</section>
</section>

<section anchor="test-mailboxidexists"><name>Test &quot;:mailboxidexists&quot;</name>
<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"></xref>), if IMAP Access Control List (ACL)
   <xref target="RFC4314"></xref> 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"></xref>).</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; test 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>

<artwork>require &quot;fileinto&quot;;
require &quot;mailboxid&quot;;

if header :contains [&quot;from&quot;] &quot;coyote&quot; {
    if mailboxidexists &quot;F6352ae03-b7f5-463c-896f-d8b48ee3&quot; {
        fileinto :mailboxid &quot;F6352ae03-b7f5-463c-896f-d8b48ee3&quot;
                            &quot;INBOX.harassment&quot;;
    } else {
        fileinto &quot;INBOX.harassment&quot;;
    }
}
</artwork>
<t>Note to implementers: this test behaves identically to the
<tt>mailboxexists</tt> test defined in <xref target="RFC5490"></xref> but operates on
mailboxids rather than mailbox names.</t>
</section>

<section anchor="interaction-with-variables-extension"><name>Interaction with variables extension</name>
<t>There is no special interaction defined, however as an objectid
is a string in this document, objectid values can contain
variable expansions if <xref target="RFC5229"></xref> is enabled.</t>
</section>

<section anchor="formal-syntax"><name>Formal Syntax</name>

<artwork>test /= &quot;mailboxidexists&quot; string-list

tag /= &quot;:mailboxid&quot; string
</artwork>
<t>If <xref target="I-D.ietf-extra-sieve-fcc"></xref> is supported:</t>

<artwork>FCC =/ [&quot;:mailboxid&quot; &lt;mailboxid: string&gt;]
</artwork>
</section>

<section anchor="security-considerations"><name>Security considerations</name>
<t>Because mailboxid is always generated by the server, implementations
MUST NOT allow sieve to make an endrun around this protection by
creating mailboxes with the specified ID by using &quot;:create&quot; and
&quot;:mailboxid&quot; in a fileinto rule for a non-existant mailbox.</t>
<t>Implementers are referred to the security considerations sections
of <xref target="RFC5228"></xref> and <xref target="RFC8474"></xref>.</t>
</section>

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

<artwork>To: iana@iana.org
Subject: Registration of new Sieve extension

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

<section anchor="acknowledgements"><name>Acknowledgements</name>
<t>This document borrows heavily from <xref target="RFC5490"></xref> for the matching
mailboxexists test, and from <xref target="I-D.ietf-extra-sieve-special-use"></xref>
for an example of modifying the fileinto command.</t>
<t>Thanks to Ned Freed and Ken Murchison and Alexey Melnikov for feedback
on the EXTRA mailing list.</t>
</section>

<section anchor="changes"><name>Changes</name>
<t>(EDITOR: remove this section before publication)</t>

<section anchor="draft-ietf-sieve-mailboxid-00"><name>draft-ietf-sieve-mailboxid-00</name>

<ul>
<li>Adopted into working group per adoption call on list</li>
<li>Updated references to old drafts which have since been published.</li>
<li>Fixed some typoes and simplified some language.</li>
<li>Removed stray leading colon on mailboxexists (thanks Alexey)</li>
<li>Added :fcc to the IANA registration description (thanks Alexey)</li>
<li>Mentioned that variables can be expanded (thanks Alexey)</li>
</ul>
</section>

<section anchor="draft-gondwana-sieve-mailboxid-02"><name>draft-gondwana-sieve-mailboxid-02</name>

<ul>
<li>Update document date by a couple of years!  Ooops, it got forgotten after
a WGLC which got not dissent.</li>
<li>Create xml2rfc v3 output.</li>
</ul>
</section>

<section anchor="draft-gondwana-sieve-mailboxid-01"><name>draft-gondwana-sieve-mailboxid-01</name>

<ul>
<li>Switch to :mailboxid tagged parameter value with fallback mailbox name.</li>
<li>Document interaction with &quot;mailbox&quot;.</li>
<li>Document interaction with &quot;special-use&quot;.</li>
<li>Document interaction with &quot;fcc&quot;.</li>
<li>Document security considerations around :mailboxid and :create.</li>
</ul>
</section>

<section anchor="draft-gondwana-sieve-mailboxid-00"><name>draft-gondwana-sieve-mailboxid-00</name>

<ul>
<li>Initial version.</li>
</ul>
</section>
</section>

</middle>

<back>
<references><name>Normative References</name>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5228.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2342.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8474.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8580.xml"/>
</references>
<references><name>Informative References</name>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5490.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-extra-sieve-special-use.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5229.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8579.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3501.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4314.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-extra-sieve-fcc.xml"/>
</references>

</back>

</rfc>
