<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' []>
<rfc ipr="trust200902" category="std" number="8621" updates="5788" submissionType="IETF" consensus="yes">
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc topblock="yes"?>
<?rfc comments="no"?>
<front>
<title abbrev="JMAP Mail">The JSON Meta Application Protocol (JMAP) for Mail</title>

<author initials="N.M." surname="Jenkins" fullname="Neil Jenkins">
<organization>Fastmail</organization>
<address>
<postal>
<street>PO Box 234, Collins St. West</street>
<city>Melbourne</city>
<code>8007</code>
<country>Australia</country>
<region>VIC</region>
</postal>
<phone></phone>
<email>neilj@fastmailteam.com</email>
<uri>https://www.fastmail.com</uri>
</address>
</author>
<author initials="C." surname="Newman" fullname="Chris Newman">
<organization>Oracle</organization>
<address>
<postal>
<street>440 E. Huntington Dr., Suite 400</street>
<city>Arcadia</city>
<code>91006</code>
<country>United States of America</country>
<region>CA</region>
</postal>
<phone></phone>
<email>chris.newman@oracle.com</email>
<uri></uri>
</address>
</author>
<date year="2019" month="August"/>

<area>Applications</area>
<workgroup>JMAP</workgroup>
<keyword>JMAP</keyword>
<keyword>JSON</keyword>
<keyword>email</keyword>


<abstract>
<t>This document specifies a data model for synchronising email data with a
server using the JSON Meta Application Protocol (JMAP).


 Clients can use this to efficiently search, access, organise, and send
 messages, and to get push notifications for fast resynchronisation when new
 messages are delivered or a change is made in another client.
</t>
</abstract>


</front>

<middle>

<section anchor="introduction" title="Introduction">
<t>The JSON Meta Application Protocol (JMAP) <xref target="RFC8620"/> is a generic protocol for synchronising data, such as mail, calendars, or contacts between a client and a server. It is optimised for mobile and web environments and aims to provide a consistent interface to different data types.
</t>
<t>This specification defines a data model for accessing a mail store over JMAP,
allowing you to query, read, organise, and submit mail for sending.
</t>
<t>The data model is designed to allow a server to provide consistent access to
the same data via IMAP <xref target="RFC3501"/> as well as JMAP. As in IMAP, a message
must belong to a mailbox; however, in JMAP, its id does not change if you move it
between mailboxes, and the server may allow it to belong to multiple mailboxes
simultaneously (often exposed in a user agent as labels rather than folders).
</t>
<t>As in IMAP, messages may also be assigned zero or more keywords: short arbitrary
strings. These are primarily intended to store metadata to inform client
display, such as unread status or whether a message has been replied to. An
IANA registry allows common semantics to be shared between clients and extended
easily in the future.
</t>
<t>A message and its replies are linked on the server by a common Thread id.
Clients may fetch the list of messages with a particular Thread id to more
easily present a threaded or conversational interface.
</t>
<t>Permissions for message access happen on a per-mailbox basis. Servers may give
the user restricted permissions for certain mailboxes, for example, if another
user's inbox has been shared as read-only with them.
</t>

<section anchor="notational-conventions" title="Notational Conventions">
<t>    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&nbsp;14 <xref target="RFC2119"/> <xref target="RFC8174"/>
    when, and only when, they appear in all capitals, as shown here.
</t>
<t>Type signatures, examples, and property descriptions in this document follow the conventions established in Section 1.1 of <xref target="RFC8620"/>. Data types defined in the core specification are also used in this document.
</t>
<t>Servers MUST support all properties specified for the new data types defined in this document.
</t>
</section>

<section anchor="terminology" title="Terminology">
<t>This document uses the same terminology as in the core JMAP specification.
</t>
<t>The terms Mailbox, Thread, Email, SearchSnippet, EmailSubmission and VacationResponse (with that specific capitalisation) are used to refer to the data types defined in this document and instances of those data types.</t>
<t>The term message refers to a document in Internet Message Format, as described in <xref target="RFC5322"/>. The Email data type represents messages in the mail store and associated metadata.</t>
</section>

<section anchor="additions-to-the-capabilities-object" title="Additions to the Capabilities Object">
<t>The capabilities object is returned as part of the JMAP Session object; see <xref target="RFC8620"/>, Section 2.
</t>
<t>This document defines three additional capability URIs.
</t>

<section anchor="urnietfparamsjmapmail" title="urn:ietf:params:jmap:mail">
<t>This represents support for the Mailbox, Thread, Email, and SearchSnippet data types and associated API methods. The value of this property in the JMAP session <spanx style="verb">capabilities</spanx> property is an empty object.
</t>
<t>The value of this property in an account's <spanx style="verb">accountCapabilities</spanx> property is an object that MUST contain the following information on server capabilities and permissions for that account:
</t>
<t>
<list style="symbols">
<t>maxMailboxesPerEmail: <spanx style="verb">UnsignedInt|null</spanx><vspace blankLines="1" />
The maximum number of Mailboxes (see <xref target="mailboxes"/>) that can be can assigned to a single Email object (see <xref target="emails"/>). This MUST be an integer &gt;=&nbsp;1, or null for no limit (or rather, the limit is always the number of Mailboxes in the account).</t>

<t>maxMailboxDepth: <spanx style="verb">UnsignedInt|null</spanx><vspace blankLines="1" />
The maximum depth of the Mailbox hierarchy (i.e., one more than the maximum number of ancestors a Mailbox may have), or null for no limit.</t>

<t>maxSizeMailboxName: <spanx style="verb">UnsignedInt</spanx><vspace blankLines="1" />
The maximum length, in (UTF-8) octets, allowed for the name of a Mailbox. This MUST be at least 100, although it is recommended servers allow more.</t>

<t>maxSizeAttachmentsPerEmail: <spanx style="verb">UnsignedInt</spanx><vspace blankLines="1" />
The maximum total size of attachments, in octets, allowed for a single Email object. A server MAY still reject the import or creation of an Email with a lower attachment size total (for example, if the body includes several megabytes of text, causing the size of the encoded MIME structure to be over some server-defined limit).
<vspace blankLines="1" />
Note that this limit is for the sum of unencoded attachment sizes. Users are generally not knowledgeable about encoding overhead, etc., nor should they need to be, so marketing and help materials normally tell them the &quot;max size attachments&quot;. This is the unencoded size they see on their hard drive, so this capability matches that and allows the client to consistently enforce what the user understands as the limit.
<vspace blankLines="1" />
The server may separately have a limit for the total size of the message <xref target="RFC5322"/>, created by combining the attachments (often base64 encoded) with the message headers and bodies. For example, suppose the server advertises <spanx style="verb">maxSizeAttachmentsPerEmail: 50000000</spanx> (50 MB). The enforced server limit may be for a message size of 70000000 octets. Even with base64 encoding and a 2 MB HTML body, 50 MB attachments would fit under this limit.</t>

<t>emailQuerySortOptions: <spanx style="verb">String[]</spanx><vspace blankLines="1" />

A list of all the values the server supports for the &quot;property&quot; field of the Comparator object in an <spanx style="verb">Email/query</spanx> sort (see <xref target="sorting" />). This MAY include properties the client does not recognise (for example, custom properties specified in a vendor extension). Clients MUST ignore any unknown properties in the list.</t>

<t>mayCreateTopLevelMailbox: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
If true, the user may create a Mailbox (see <xref target="mailboxes"/>) in this account with
a null parentId. (Permission for creating a child of an existing Mailbox is given by the <spanx style="verb">myRights</spanx> property on that Mailbox.)</t>
</list>
</t>
</section>

<section anchor="urnietfparamsjmapsubmission" title="urn:ietf:params:jmap:submission">
<t>This represents support for the Identity and EmailSubmission data types and associated API methods. The value of this property in the JMAP session <spanx style="verb">capabilities</spanx> property is an empty object.
</t>
<t>The value of this property in an account's <spanx style="verb">accountCapabilities</spanx> property is an object that MUST contain the following information on server capabilities and permissions for that account:
</t>
<t>
<list style="symbols">
<t>maxDelayedSend: <spanx style="verb">UnsignedInt</spanx><vspace blankLines="1" />
The number in seconds of the maximum delay the server supports in sending
(see the EmailSubmission object description). This is 0 if the server does
not support delayed send.</t>

<t>submissionExtensions: <spanx style="verb">String[String[]]</spanx><vspace blankLines="1" />
The set of SMTP submission extensions supported by the server, which the client may use when creating an EmailSubmission object (see <xref target="email-submission"/>). Each key in the object is the <spanx style="verb">ehlo-name</spanx>, and the value is a list of <spanx style="verb">ehlo-args</spanx>.
<vspace blankLines="1" />
A JMAP implementation that talks to a submission server <xref target="RFC6409"/> SHOULD have a configuration setting that allows an administrator to modify the set of submission EHLO capabilities it may expose on this property. This allows a JMAP server to easily add access to a new submission extension without code changes. By default, the JMAP server should hide EHLO capabilities that have to do with the transport mechanism and thus are only relevant to the JMAP server (for example, PIPELINING, CHUNKING, or STARTTLS).
<vspace blankLines="1" />
Examples of Submission extensions to include:
<list style="symbols">
<t>FUTURERELEASE <xref target="RFC4865"/></t>
<t>SIZE <xref target="RFC1870"/></t>
<t>DSN <xref target="RFC3461"/></t>
<t>DELIVERYBY <xref target="RFC2852"/></t>
<t>MT-PRIORITY <xref target="RFC6710"/></t>
</list>
A JMAP server MAY advertise an extension and implement the semantics of that extension locally on the JMAP server even if a submission server used by JMAP doesn't implement it.
<vspace blankLines="1" />
The full IANA registry of submission extensions can be found at
&lt;https://www.iana.org/assignments/mail-parameters&gt;.</t>
</list>
</t>
</section>

<section anchor="urnietfparamsjmapvacationresponse" title="urn:ietf:params:jmap:vacationresponse">
<t>This represents support for the VacationResponse data type and associated API methods. The value of this property is an empty object in both the JMAP session <spanx style="verb">capabilities</spanx> property and an account's <spanx style="verb">accountCapabilities</spanx> property.
</t>
</section>
</section>

<section anchor="data-type-support-in-different-accounts" title="Data Type Support in Different Accounts">
<t>The server MUST include the appropriate capability strings as keys in the <spanx style="verb">accountCapabilities</spanx> property of any account with which the user may use the data types represented by that URI. Supported data types may differ between accounts the user has access to. For example, in the user's personal account, they may have access to all three sets of data, but in a shared account, they may only have data for <spanx style="verb">urn:ietf:params:jmap:mail</spanx>. This means they can access Mailbox/Thread/Email data in the shared account but are not allowed to send as that account (and so do not have access to Identity/EmailSubmission objects) or view/set its VacationResponse.
</t>
</section>

<section anchor="push" title="Push">
<t>Servers MUST support the JMAP push mechanisms, as specified in <xref target="RFC8620"/>, Section 7, to receive notifications when the state changes for any of the types defined in this specification.
</t>
<t>In addition, servers that implement the &quot;urn:ietf:params:jmap:mail&quot; capability MUST support pushing state changes for a type called &quot;EmailDelivery&quot;. There are no methods to act on this type; it only exists as part of the push mechanism. The state string for this MUST change whenever a new Email is added to the store, but it SHOULD NOT change upon any other change to the Email objects, for example, if one is marked as read or deleted.
</t>
<t>Clients in battery-constrained environments may wish to delay fetching changes initiated by the user but fetch new Emails immediately so they can notify the user. To do this, they can register for pushes for the EmailDelivery type rather than the Email type (as defined in <xref target="emails"/>).
</t>

<section anchor="example" title="Example">
<t>The client has registered for push notifications (see <xref target="RFC8620"/>) just for the EmailDelivery type. The user marks an Email as read on another device, causing the state string for the Email type to change; however, as nothing new was added to the store, the EmailDelivery state does not change and nothing is pushed to the client. A new message arrives in the user's inbox, again causing the Email state to change. This time, the EmailDelivery state also changes, and a StateChange object is pushed to the client with the new state string. The client may then resync to fetch the new Email immediately.
</t>
</section>
</section>

<section anchor="ids" title="Ids">
<t>If a JMAP Mail server also provides an IMAP interface to the data and supports IMAP Extension for Object Identifiers <xref target="RFC8474"/>, the ids SHOULD be the same for Mailbox, Thread, and Email objects in JMAP.
</t>
</section>
</section>

<section anchor="mailboxes" title="Mailboxes">
<t>A Mailbox represents a named set of Email objects. This is the primary mechanism
for organising messages within an account. It is analogous to a folder or a
label in other systems. A Mailbox may perform a certain role in the system;
see below for more details.
</t>
<t>For compatibility with IMAP, an Email MUST belong to one or more Mailboxes. The Email id does not change if the Email changes Mailboxes.
</t>
<t>A <spanx style="strong">Mailbox</spanx> object has the following properties:
</t>
<t>
<list style="symbols">
<t>id: <spanx style="verb">Id</spanx> (immutable; server-set)<vspace blankLines="1" />
The id of the Mailbox.</t>

<t>name: <spanx style="verb">String</spanx><vspace blankLines="1" />
User-visible name for the Mailbox, e.g., &quot;Inbox&quot;. This MUST be a Net-Unicode string <xref target="RFC5198"/> of at least 1 character in length, subject to the maximum size given in the capability object. There MUST NOT be two sibling Mailboxes with both the same parent and the same name. Servers MAY reject names that violate server policy (e.g., names containing a slash (/) or control characters).</t>

<t>parentId: <spanx style="verb">Id|null</spanx> (default: null)<vspace blankLines="1" />
The Mailbox id for the parent of this Mailbox, or null if this Mailbox is at the top level. Mailboxes form acyclic graphs (forests) directed by the child-to-parent relationship. There MUST NOT be a loop.</t>

<t>role: <spanx style="verb">String|null</spanx> (default: null)<vspace blankLines="1" />
Identifies Mailboxes that have a particular common purpose (e.g., the &quot;inbox&quot;), regardless of the <spanx style="verb">name</spanx> property (which may be localised).
<vspace blankLines="1" />
This value is shared with IMAP (exposed in IMAP via the SPECIAL-USE extension <xref target="RFC6154"/>). However, unlike in IMAP, a Mailbox MUST only have a single role, and there MUST NOT be two Mailboxes in the same account with the same role. Servers providing IMAP access to the same data are encouraged to enforce these extra restrictions in IMAP as well. Otherwise, modifying the IMAP attributes to ensure compliance when exposing the data over JMAP is implementation dependent.
<vspace blankLines="1" />
The value MUST be one of the Mailbox attribute names listed in the IANA "IMAP
Mailbox Name Attributes" registry at
&lt;https://www.iana.org/assignments/imap-mailbox-name-attributes/&gt;, as
established in <xref target="RFC8457"/>, converted to lowercase. New roles may
be established here in the future.
<vspace blankLines="1" />
An account is not required to have Mailboxes with any particular roles.</t>

<t>sortOrder: <spanx style="verb">UnsignedInt</spanx> (default: 0)<vspace blankLines="1" />
Defines the sort order of Mailboxes when presented in the client's UI, so it
is consistent between devices. The number MUST be an integer in the range
0 &lt;= sortOrder &lt; 2^31.
<vspace blankLines="1" />
A Mailbox with a lower order should be displayed before a Mailbox with a higher order (that has the same parent) in any Mailbox listing in the client's UI. Mailboxes with equal order SHOULD be sorted in alphabetical order by name. The sorting should take into account locale-specific character order convention.</t>
<t>totalEmails: <spanx style="verb">UnsignedInt</spanx> (server-set)<vspace blankLines="1" />
The number of Emails in this Mailbox.</t>

<t>unreadEmails: <spanx style="verb">UnsignedInt</spanx> (server-set)<vspace blankLines="1" />
The number of Emails in this Mailbox that have neither the <spanx style="verb">$seen</spanx> keyword nor the <spanx style="verb">$draft</spanx> keyword.</t>

<t>totalThreads: <spanx style="verb">UnsignedInt</spanx> (server-set)<vspace blankLines="1" />
The number of Threads where at least one Email in the Thread is in this Mailbox.</t>

<t>unreadThreads: <spanx style="verb">UnsignedInt</spanx> (server-set)<vspace blankLines="1" />
An indication of the number of &quot;unread&quot; Threads in the Mailbox.
<vspace blankLines="1" />
For compatibility with existing implementations, the way &quot;unread Threads&quot; is
determined is not mandated in this document. The simplest solution to implement is simply the number of Threads where at least one Email in the Thread is both in this Mailbox and has neither the <spanx style="verb">$seen</spanx> nor <spanx style="verb">$draft</spanx> keywords.
<vspace blankLines="1" />
However, a quality implementation will return the number of unread items the user would see if they opened that Mailbox. A Thread is shown as unread if it contains any unread Emails that will be displayed when the Thread is opened. Therefore, <spanx style="verb">unreadThreads</spanx> should be the number of Threads where at least one Email in the Thread has neither the <spanx style="verb">$seen</spanx> nor the <spanx style="verb">$draft</spanx> keyword AND at least one Email in the Thread is in this Mailbox. Note that the unread Email does not need to be the one in this Mailbox. In addition, the trash Mailbox (that is, a Mailbox whose <spanx style="verb">role</spanx> is <spanx style="verb">trash</spanx>) requires special treatment:
<list style="numbers">
<t>Emails that are <spanx style="strong">only</spanx> in the trash (and no other Mailbox) are ignored when calculating the <spanx style="verb">unreadThreads</spanx> count of other Mailboxes.</t>
<t>Emails that are <spanx style="strong">not</spanx> in the trash are ignored when calculating the <spanx style="verb">unreadThreads</spanx> count for the trash Mailbox.</t>
</list>
The result of this is that Emails in the trash are treated as though they are in a separate Thread for the purposes of unread counts. It is expected that clients will hide Emails in the trash when viewing a Thread in another Mailbox, and vice versa. This allows you to delete a single Email to the trash out of a Thread.
<vspace blankLines="1" />
For example, suppose you have an account where the entire contents is a single Thread with 2 Emails: an unread Email in the trash and a read Email in the inbox. The <spanx style="verb">unreadThreads</spanx> count would be 1 for the trash and 0 for the inbox.</t>

<t>myRights: <spanx style="verb">MailboxRights</spanx> (server-set)<vspace blankLines="1" />
The set of rights (Access Control Lists (ACLs)) the user has in relation to this Mailbox. These are backwards compatible with IMAP ACLs, as defined in <xref target="RFC4314"/>. A <spanx style="strong">MailboxRights</spanx> object has the following properties:
<list style="symbols">
<t>mayReadItems: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
If true, the user may use this Mailbox as part of a filter in an <spanx style="verb">Email/query</spanx> call, and the Mailbox may be included in the <spanx style="verb">mailboxIds</spanx> property of Email objects. Email objects may be fetched if they are in <spanx style="strong">at least one</spanx> Mailbox with this permission. If a sub-Mailbox is shared but not the parent Mailbox, this may be false. Corresponds to IMAP ACLs <spanx style="verb">lr</spanx> (if mapping from IMAP, both are required for this to be true).</t>

<t>mayAddItems: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
The user may add mail to this Mailbox (by either creating a new Email or moving an existing one). Corresponds to IMAP ACL <spanx style="verb">i</spanx>.</t>

<t>mayRemoveItems: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
The user may remove mail from this Mailbox (by either changing the Mailboxes of an Email or destroying the Email). Corresponds to IMAP ACLs <spanx style="verb">te</spanx> (if mapping from IMAP, both are required for this to be true).</t>

<t>maySetSeen: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
The user may add or remove the <spanx style="verb">$seen</spanx> keyword to/from an Email. If an Email belongs to multiple Mailboxes, the user may only modify <spanx style="verb">$seen</spanx> if they have this permission for <spanx style="strong">all</spanx> of the Mailboxes. Corresponds to IMAP ACL <spanx style="verb">s</spanx>.</t>

<t>maySetKeywords: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
The user may add or remove any keyword other than <spanx style="verb">$seen</spanx> to/from an Email. If an Email belongs to multiple Mailboxes, the user may only modify keywords if they have this permission for <spanx style="strong">all</spanx> of the Mailboxes. Corresponds to IMAP ACL <spanx style="verb">w</spanx>.</t>

<t>mayCreateChild: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
The user may create a Mailbox with this Mailbox as its parent. Corresponds to IMAP ACL <spanx style="verb">k</spanx>.</t>

<t>mayRename: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
The user may rename the Mailbox or make it a child of another Mailbox. Corresponds to IMAP ACL <spanx style="verb">x</spanx> (although this covers both rename and delete permissions).</t>

<t>mayDelete: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
The user may delete the Mailbox itself. Corresponds to IMAP ACL <spanx style="verb">x</spanx> (although this covers both rename and delete permissions).</t>

<t>maySubmit: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
Messages may be submitted directly to this Mailbox. Corresponds to IMAP ACL <spanx style="verb">p</spanx>.</t>
</list></t>

<t>isSubscribed: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
Has the user indicated they wish to see this Mailbox in their client? This SHOULD default to false for Mailboxes in shared accounts the user has access to and true for any new Mailboxes created by the user themself. This MUST be stored separately per user where multiple users have access to a shared Mailbox.
<vspace blankLines="1" />
A user may have permission to access a large number of shared accounts, or a shared account with a very large set of Mailboxes, but only be interested in the contents of a few of these. Clients may choose to only display Mailboxes where the <spanx style="verb">isSubscribed</spanx> property is set to true, and offer a separate UI to allow the user to see and subscribe/unsubscribe from the full set of Mailboxes. However, clients MAY choose to ignore this property, either entirely for ease of implementation or just for an account where <spanx style="verb">isPersonal</spanx> is true (indicating it is the user's own rather than a shared account).
<vspace blankLines="1" />
This property corresponds to IMAP <xref target="RFC3501"/> mailbox subscriptions.</t>
</list>
</t>
<t>For IMAP compatibility, an Email in both the trash and another Mailbox SHOULD be treated by the client as existing in both places (i.e., when emptying the trash, the client should just remove it from the trash Mailbox and leave it in the other Mailbox).
</t>
<t>The following JMAP methods are supported.
</t>

<section anchor="mailboxget" title="Mailbox/get">
<t>This is a standard &quot;/get&quot; method as described in <xref target="RFC8620"/>,
Section 5.1. The <spanx style="verb">ids</spanx> argument may be <spanx
style="verb">null</spanx> to fetch all at once.
</t>
</section>

<section anchor="mailboxchanges" title="Mailbox/changes">
<t>This is a standard &quot;/changes&quot; method as described in <xref target="RFC8620"/>, Section 5.2 but with one extra argument to the response:
</t>
<t>
<list style="symbols">
<t>updatedProperties: <spanx style="verb">String[]|null</spanx><vspace blankLines="1" />
If only the "totalEmails", "unreadEmails", "totalThreads", and/or "unreadThreads" Mailbox properties have changed since the old state, this will be the list of properties that may have changed. If the server is unable to tell if only counts have changed, it MUST just be null.</t>
</list>
</t>
<t>Since counts frequently change but other properties are generally only changed rarely, the server can help the client optimise data transfer by keeping track of changes to Email/Thread counts separate from other state changes. The <spanx style="verb">updatedProperties</spanx> array may be used directly via a back-reference in a subsequent <spanx style="verb">Mailbox/get</spanx> call in the same request, so only these properties are returned if nothing else has changed.
</t>
</section>

<section anchor="mailboxquery" title="Mailbox/query">
<t>This is a standard &quot;/query&quot; method as described in <xref target="RFC8620"/>, Section 5.5 but with the following additional request argument:
</t>

<t>
<list style="symbols">
<t>sortAsTree: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />

If true, when sorting the query results and comparing Mailboxes A and B:
<list style="symbols">
<t>If A is an ancestor of B, it always comes first regardless of the sort comparators. Similarly, if A is descendant of B, then B always comes
first.</t>

<t>Otherwise, if A and B do not share a <spanx style="verb">parentId</spanx>, find the nearest
ancestors of each that do have the same <spanx style="verb">parentId</spanx> and compare the sort
properties on those Mailboxes instead.</t>

</list>
The result of this is that the Mailboxes are sorted as a tree according to the parentId properties, with each set of children with a common parent sorted according to the standard sort comparators.</t>

<t>filterAsTree: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
If true, a Mailbox is only included in the query if all its ancestors are
also included in the query according to the filter.</t>
</list>
</t>
<t>A <spanx style="strong">FilterCondition</spanx> object has the following properties, any of which may be omitted:
</t>
<t>
<list style="symbols">
<t>parentId: <spanx style="verb">Id|null</spanx><vspace blankLines="1" />
The Mailbox <spanx style="verb">parentId</spanx> property must match the given value exactly.</t>

<t>name: <spanx style="verb">String</spanx><vspace blankLines="1" />
The Mailbox <spanx style="verb">name</spanx> property contains the given string.</t>

<t>role: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The Mailbox <spanx style="verb">role</spanx> property must match the given value exactly.</t>

<t>hasAnyRole: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
If true, a Mailbox matches if it has any non-null value for its <spanx style="verb">role</spanx> property.</t>

<t>isSubscribed: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
The <spanx style="verb">isSubscribed</spanx> property of the Mailbox must be identical to the value given to match the condition.</t>
</list>
</t>

<t>A Mailbox object matches the FilterCondition if and only if all of the given conditions match. If zero properties are specified, it is automatically true for all objects.
</t>
<t>The following Mailbox properties MUST be supported for sorting:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">sortOrder</spanx></t>
<t><spanx style="verb">name</spanx></t>
</list>
</t>
</section>

<section anchor="mailboxquerychanges" title="Mailbox/queryChanges">
<t>This is a standard &quot;/queryChanges&quot; method as described in <xref target="RFC8620"/>, Section 5.6.
</t>
</section>

<section anchor="mailboxset" title="Mailbox/set">
<t>This is a standard &quot;/set&quot; method as described in <xref target="RFC8620"/>, Section 5.3 but with the following additional request argument:
</t>
<t>
<list style="symbols">
<t>onDestroyRemoveEmails: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
If false, any attempt to destroy a Mailbox that still has Emails in it will be rejected with a <spanx style="verb">mailboxHasEmail</spanx> SetError. If true, any Emails that were in the Mailbox will be removed from it, and if in no other Mailboxes, they will be destroyed when the Mailbox is destroyed.</t>
</list>
</t>
<t>The following extra SetError types are defined:
</t>
<t>For <spanx style="verb">destroy</spanx>:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">mailboxHasChild</spanx>: The Mailbox still has at least one child Mailbox. The
client MUST remove these before it can delete the parent Mailbox.</t>

<t><spanx style="verb">mailboxHasEmail</spanx>: The Mailbox has at least one Email assigned to it, and
the <spanx style="verb">onDestroyRemoveEmails</spanx> argument was false.</t>
</list>
</t>
</section>

<section anchor="example-1" title="Example">
<t>Fetching all Mailboxes in an account:
</t>

<figure align="center"><artwork align="center">
[[ "Mailbox/get", {
  "accountId": "u33084183",
  "ids": null
}, "0" ]]
</artwork></figure>
<t>And the response:
</t>

<figure align="center"><artwork align="center">
[[ "Mailbox/get", {
  "accountId": "u33084183",
  "state": "78540",
  "list": [{
    "id": "MB23cfa8094c0f41e6",
    "name": "Inbox",
    "parentId": null,
    "role": "inbox",
    "sortOrder": 10,
    "totalEmails": 16307,
    "unreadEmails": 13905,
    "totalThreads": 5833,
    "unreadThreads": 5128,
    "myRights": {
      "mayAddItems": true,
      "mayRename": false,
      "maySubmit": true,
      "mayDelete": false,
      "maySetKeywords": true,
      "mayRemoveItems": true,
      "mayCreateChild": true,
      "maySetSeen": true,
      "mayReadItems": true
    },
    "isSubscribed": true
  }, {
    "id": "MB674cc24095db49ce",
    "name": "Important mail",
    ...
  }, ... ],
  "notFound": []
}, "0" ]]
</artwork></figure>
<t>Now suppose an Email is marked read, and we get a push update that the Mailbox state has changed. You might fetch the updates like this:
</t>

<figure align="center"><artwork align="center">
[[ "Mailbox/changes", {
  "accountId": "u33084183",
  "sinceState": "78540"
}, "0" ],
[ "Mailbox/get", {
  "accountId": "u33084183",
  "#ids": {
    "resultOf": "0",
    "name": "Mailbox/changes",
    "path": "/created"
  }
}, "1" ],
[ "Mailbox/get", {
  "accountId": "u33084183",
  "#ids": {
    "resultOf": "0",
    "name": "Mailbox/changes",
    "path": "/updated"
  },
  "#properties": {
    "resultOf": "0",
    "name": "Mailbox/changes",
    "path": "/updatedProperties"
  }
}, "2" ]]
</artwork></figure>
<t>This fetches the list of ids for created/updated/destroyed Mailboxes, then using back-references, it fetches the data for just the created/updated Mailboxes in the same request. The response may look something like this:
</t>

<figure align="center"><artwork align="center">
[[ "Mailbox/changes", {
  "accountId": "u33084183",
  "oldState": "78541",
  "newState": "78542",
  "hasMoreChanges": false,
  "updatedProperties": [
    "totalEmails", "unreadEmails",
    "totalThreads", "unreadThreads"
  ],
  "created": [],
  "updated": ["MB23cfa8094c0f41e6"],
  "destroyed": []
}, "0" ],
[ "Mailbox/get", {
  "accountId": "u33084183",
  "state": "78542",
  "list": [],
  "notFound": []
}, "1" ],
[ "Mailbox/get", {
  "accountId": "u33084183",
  "state": "78542",
  "list": [{
    "id": "MB23cfa8094c0f41e6",
    "totalEmails": 16307,
    "unreadEmails": 13903,
    "totalThreads": 5833,
    "unreadThreads": 5127
  }],
  "notFound": []
}, "2" ]]
</artwork></figure>
<t>Here's an example where we try to rename one Mailbox and destroy another:
</t>

<figure align="center"><artwork align="center">
[[ "Mailbox/set", {
  "accountId": "u33084183",
  "ifInState": "78542",
  "update": {
    "MB674cc24095db49ce": {
      "name": "Maybe important mail"
    }
  },
  "destroy": [ "MB23cfa8094c0f41e6" ]
}, "0" ]]
</artwork></figure>
<t>Suppose the rename succeeds, but we don't have permission to destroy the Mailbox we tried to destroy; we might get back:
</t>

<figure align="center"><artwork align="center">
[[ "Mailbox/set", {
  "accountId": "u33084183",
  "oldState": "78542",
  "newState": "78549",
  "updated": {
      "MB674cc24095db49ce": null
  },
  "notDestroyed": {
    "MB23cfa8094c0f41e6": {
      "type": "forbidden"
    }
  }
}, "0" ]]
</artwork></figure>
</section>
</section>

<section anchor="threads" title="Threads">
<t>Replies are grouped together with the original message to form a Thread. In JMAP, a Thread is simply a flat list of Emails, ordered by date. Every Email MUST belong to a Thread, even if it is the only Email in the Thread.
</t>
<t>The exact algorithm for determining whether two Emails belong to the same Thread is not mandated in this spec to allow for compatibility with different existing systems. For new implementations, it is suggested that two messages belong in the same Thread if both of the following conditions apply:
</t>
<t>
<list style="numbers">
<t>An identical message id <xref target="RFC5322" /> appears in both messages in any of the
 Message-Id, In-Reply-To, and References header fields.</t>

<t>After stripping automatically added prefixes such as &quot;Fwd:&quot;, &quot;Re:&quot;,
 &quot;[List-Tag]&quot;, etc., and ignoring white space, the subjects are the same. This avoids the situation where a person replies to an old message as a convenient way of finding the right recipient to send to but changes the subject and starts a new conversation.</t>
</list>
</t>
<t>If messages are delivered out of order for some reason, a user may have two Emails in the same Thread but without headers that associate them with each other. The arrival of a third Email may provide the missing references to join them all together into a single Thread. Since the <spanx style="verb">threadId</spanx> of an Email is immutable, if the server wishes to merge the Threads, it MUST handle this by deleting and reinserting (with a new Email id) the Emails that change <spanx style="verb">threadId</spanx>.
</t>
<t>A <spanx style="strong">Thread</spanx> object has the following properties:
</t>
<t>
<list style="symbols">
<t>id: <spanx style="verb">Id</spanx> (immutable; server-set)<vspace blankLines="1" />
The id of the Thread.</t>

<t>emailIds: <spanx style="verb">Id[]</spanx> (server-set)<vspace blankLines="1" />
The ids of the Emails in the Thread, sorted by the <spanx style="verb">receivedAt</spanx> date of the Email, oldest first. If two Emails have an identical date, the sort is server dependent but MUST be stable (sorting by id is recommended).</t>
</list>
</t>
<t>The following JMAP methods are supported.
</t>

<section anchor="threadget" title="Thread/get">
<t>This is a standard &quot;/get&quot; method as described in <xref target="RFC8620"/>, Section 5.1.
</t>

<section anchor="example-2" title="Example">
<t>Request:
</t>

<figure align="center"><artwork align="center">
[[ "Thread/get", {
  "accountId": "acme",
  "ids": ["f123u4", "f41u44"]
}, "#1" ]]
</artwork></figure>
<t>with response:
</t>

<figure align="center"><artwork align="center">
[[ "Thread/get", {
  "accountId": "acme",
  "state": "f6a7e214",
  "list": [
    {
      "id": "f123u4",
      "emailIds": [ "eaa623", "f782cbb"]
    },
    {
      "id": "f41u44",
      "emailIds": [ "82cf7bb" ]
    }
  ],
  "notFound": []
}, "#1" ]]
</artwork></figure>
</section>
</section>

<section anchor="threadchanges" title="Thread/changes">
<t>This is a standard &quot;/changes&quot; method as described in <xref target="RFC8620"/>, Section 5.2.
</t>
</section>
</section>

<section anchor="emails" title="Emails">
<t>An <spanx style="strong">Email</spanx> object is a representation of a message <xref target="RFC5322"/>, which allows clients to avoid the complexities of MIME parsing, transfer encoding, and character encoding.
</t>

<section anchor="properties-of-the-email-object" title="Properties of the Email Object">
<t>Broadly, a message consists of two parts: a list of header fields and then a body. The Email data type provides a way to access the full structure or to use simplified properties and avoid some complexity if this is sufficient for the client application.
</t>
<t>While raw headers can be fetched and set, the vast majority of clients should use an appropriate parsed form for each of the header fields it wants to process, as this allows it to avoid the complexities of various encodings that are required in a valid message per RFC 5322.
</t>
<t>The body of a message is normally a MIME-encoded set of documents in a tree structure. This may be arbitrarily nested, but the majority of email clients present a flat model of a message body (normally plaintext or HTML) with a set of attachments. Flattening the MIME structure to form this model can be difficult and causes inconsistency between clients. Therefore, in addition to the <spanx style="verb">bodyStructure</spanx> property, which gives the full tree, the Email object contains 3 alternate properties with flat lists of body parts:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">textBody</spanx>/<spanx style="verb">htmlBody</spanx>: These provide a list of parts that should be
rendered sequentially as the &quot;body&quot; of the message. This is a list rather than a single part as messages may have headers and/or footers appended/prepended as separate parts when they are transmitted, and some clients send text and images intended to be displayed inline in the body (or even videos and sound clips) as multiple parts rather than a single HTML part with referenced images.
<vspace blankLines="1" />
Because MIME allows for multiple representations of the same data (using <spanx style="verb">multipart/alternative</spanx>), there is a <spanx style="verb">textBody</spanx> property (which prefers a plaintext representation) and an <spanx style="verb">htmlBody</spanx> property (which prefers an HTML representation) to accommodate the two most common client requirements. The same part may appear in both lists where there is no alternative between the two.
</t>
<t><spanx style="verb">attachments</spanx>: This provides a list of parts that should be presented as
&quot;attachments&quot; to the message. Some images may be solely there for embedding within an HTML body part; clients may wish to not present these as attachments in the user interface if they are displaying the HTML with the embedded images directly. Some parts may also be in htmlBody/textBody; again, clients may wish to not present these as attachments in the user interface if rendered as part of the body.</t>
</list>
</t>
<t>The <spanx style="verb">bodyValues</spanx> property allows for clients to fetch the value of text parts directly without having to do a second request for the blob and to have the server handle decoding the charset into unicode. This data is in a separate property rather than on the EmailBodyPart object to avoid duplication of large amounts of data, as the same part may be included twice if the client fetches more than one of bodyStructure, textBody, and htmlBody.
</t>
<t>In the following subsections, the common notational convention for wildcards has been adopted for content types, so <spanx style="verb">foo/*</spanx> means any content type that starts with <spanx style="verb">foo/</spanx>.
</t>
<t>Due to the number of properties involved, the set of Email properties is specified over the following four subsections. This is purely for readability; all properties are top-level peers.
</t>

<section anchor="metadata" title="Metadata">
<t>These properties represent metadata about the message in the mail store and are not derived from parsing the message itself.
</t>
<t>
<list style="symbols">
<t>id: <spanx style="verb">Id</spanx> (immutable; server-set)<vspace blankLines="1" />
The id of the Email object. Note that this is the JMAP object id, NOT the Message-ID header field value of the message <xref target="RFC5322"/>.</t>

<t>blobId: <spanx style="verb">Id</spanx> (immutable; server-set)<vspace blankLines="1" />
The id representing the raw octets of the message <xref target="RFC5322"/> for this Email. This may be used to download the raw original message or to attach it directly to another Email, etc.</t>

<t>threadId: <spanx style="verb">Id</spanx> (immutable; server-set)<vspace blankLines="1" />
The id of the Thread to which this Email belongs.</t>

<t>mailboxIds: <spanx style="verb">Id[Boolean]</spanx><vspace blankLines="1" />
The set of Mailbox ids this Email belongs to. An Email in the mail store MUST belong to one or more Mailboxes at all times (until it is destroyed). The set is represented as an object, with each key being a Mailbox id.  The value for each key in the object MUST be true.</t>

<t>keywords: <spanx style="verb">String[Boolean]</spanx> (default: {})<vspace blankLines="1" />
A set of keywords that apply to the Email. The set is represented as an object, with the keys being the keywords.  The value for each key in the object MUST be true.
<vspace blankLines="1" />
Keywords are shared with IMAP. The six system keywords from IMAP get special treatment. The following four keywords have their first character changed from <spanx style="verb">\</spanx> in IMAP to <spanx style="verb">$</spanx> in JMAP and have particular semantic meaning:
<list style="symbols">
<t><spanx style="verb">$draft</spanx>: The Email is a draft the user is composing.</t>
<t><spanx style="verb">$seen</spanx>: The Email has been read.</t>
<t><spanx style="verb">$flagged</spanx>: The Email has been flagged for urgent/special attention.</t>
<t><spanx style="verb">$answered</spanx>: The Email has been replied to.</t>
</list>
The IMAP <spanx style="verb">\Recent</spanx> keyword is not exposed via JMAP. The IMAP <spanx style="verb">\Deleted</spanx> keyword is also not present: IMAP uses a delete+expunge model, which JMAP does not. Any message with the <spanx style="verb">\Deleted</spanx> keyword MUST NOT be visible via JMAP (and so are not counted in the "totalEmails", "unreadEmails", "totalThreads", and "unreadThreads" Mailbox properties).
<vspace blankLines="1" />
Users may add arbitrary keywords to an Email. For compatibility with IMAP, a
keyword is a case-insensitive string of 1-255 characters in the ASCII subset
%x21-%x7e (excludes control chars and space), and it MUST NOT include any of
these characters:

<figure align="center"><artwork align="center">( ) { ] % * " \</artwork></figure>

<vspace blankLines="1" />
Because JSON is case sensitive, servers MUST return keywords in lowercase.
<vspace blankLines="1" />
The IANA "IMAP and JMAP Keywords" registry at
&lt;https://www.iana.org/assignments/imap-jmap-keywords/&gt; as established in
<xref target="RFC5788"/> assigns semantic meaning to some other keywords in
common use. New keywords may be established here in the future. In particular,
note:
<list style="symbols">
<t><spanx style="verb">$forwarded</spanx>: The Email has been forwarded.</t>
<t><spanx style="verb">$phishing</spanx>: The Email is highly likely to be phishing. Clients SHOULD warn users to take care when viewing this Email and disable links and attachments.</t>
<t><spanx style="verb">$junk</spanx>: The Email is definitely spam. Clients SHOULD set this flag when users report spam to help train automated spam-detection systems.</t>

<t><spanx style="verb">$notjunk</spanx>: The Email is definitely not spam. Clients SHOULD set this flag when users indicate an Email is legitimate, to help train automated spam-detection systems.</t>
</list></t>

<t>size: <spanx style="verb">UnsignedInt</spanx> (immutable; server-set)<vspace blankLines="1" />
The size, in octets, of the raw data for the message <xref target="RFC5322"/> (as referenced by the <spanx style="verb">blobId</spanx>, i.e., the number of octets in the file the user would download).</t>
<t>receivedAt: <spanx style="verb">UTCDate</spanx> (immutable; default: time of creation on server)<vspace blankLines="1" />
The date the Email was received by the message store. This is the <spanx style="verb">internal date</spanx> in IMAP <xref target="RFC3501"/>.</t>
</list>
</t>
</section>

<section anchor="header-fields-parsed-forms" title="Header Fields Parsed Forms">
<t>Header field properties are derived from the message header fields <xref target="RFC5322"/> <xref target="RFC6532"/>. All header fields may be fetched in a raw form. Some header fields may also be fetched in a parsed form. The structured form that may be fetched depends on the header. The forms are defined in the subsections that follow.
</t>

<section anchor="raw" title="Raw">
<t>Type: <spanx style="verb">String</spanx>
</t>
<t>The raw octets of the header field value from the first octet following the header field name terminating colon, up to but excluding the header field terminating CRLF. Any standards-compliant message MUST be either ASCII (RFC 5322) or UTF-8 (RFC 6532); however, other encodings exist in the wild. A server SHOULD replace any octet or octet run with the high bit set that violates UTF-8 syntax with the unicode replacement character (U+FFFD). Any NUL octet MUST be dropped.
</t>
<t>This form will typically have a leading space, as most generated messages
insert a space after the colon that terminates the header field name.
</t>
</section>

<section anchor="text" title="Text">
<t>Type: <spanx style="verb">String</spanx>
</t>
<t>The header field value with:
</t>
<t>
<list style="numbers">
<t>White space unfolded (as defined in <xref target="RFC5322"/>, Section 2.2.3).</t>
<t>The terminating CRLF at the end of the value removed.</t>
<t>Any SP characters at the beginning of the value removed.</t>

<t>Any syntactically correct encoded sections <xref target="RFC2047"/> with a known
character set decoded. Any NUL octets or control characters encoded per <xref target="RFC2047"/> are dropped from the decoded value. Any text that looks like syntax per <xref target="RFC2047"/> but violates placement or white space rules per <xref target="RFC2047"/> MUST NOT be decoded.</t>

<t>The resulting unicode converted to Normalization Form C (NFC) form.</t>
</list>
</t>
<t>If any decodings fail, the parser SHOULD insert a unicode replacement
character (U+FFFD) and attempt to continue as much as possible.
</t>
<t>To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the following header fields:
</t>
<t>
<list style="symbols">
<t>Subject</t>
<t>Comments</t>
<t>Keywords</t>
<t>List-Id</t>
<t>Any header field not defined in <xref target="RFC5322"/> or <xref target="RFC2369"/></t>
</list>
</t>
</section>

<section anchor="addresses" title="Addresses">
<t>Type: <spanx style="verb">EmailAddress[]</spanx>
</t>
<t>The header field is parsed as an <spanx style="verb">address-list</spanx> value, as specified in <xref target="RFC5322"/>, Section 3.4, into the <spanx style="verb">EmailAddress[]</spanx> type. There is an EmailAddress item for each <spanx style="verb">mailbox</spanx> parsed from the <spanx style="verb">address-list</spanx>. Group and comment information is discarded.
</t>
<t>An <spanx style="strong">EmailAddress</spanx> object has the following properties:
</t>
<t>
<list style="symbols">
<t>name: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The <spanx style="verb">display-name</spanx> of the <spanx style="verb">mailbox</spanx> <xref target="RFC5322"/>. If this is a <spanx style="verb">quoted-string</spanx>:
<list style="numbers">
<t>The surrounding DQUOTE characters are removed.</t>
<t>Any <spanx style="verb">quoted-pair</spanx> is decoded.</t>
<t>White space is unfolded, and then any leading and trailing white space
is removed.</t>
</list>
If there is no <spanx style="verb">display-name</spanx> but there is a <spanx style="verb">comment</spanx> immediately following the <spanx style="verb">addr-spec</spanx>, the value of this SHOULD be used instead. Otherwise, this property is null.</t>

<t>email: <spanx style="verb">String</spanx><vspace blankLines="1" />
The <spanx style="verb">addr-spec</spanx> of the <spanx style="verb">mailbox</spanx> <xref target="RFC5322"/>.</t>
</list>
</t>
<t>Any syntactically correct encoded sections <xref target="RFC2047"/> with a known encoding MUST be decoded, following the same rules as for the Text form (see <xref target="text"/>).
</t>
<t>Parsing SHOULD be best effort in the face of invalid structure to
accommodate invalid messages and semi-complete drafts. EmailAddress objects
MAY have an <spanx style="verb">email</spanx> property that does not conform to the <spanx style="verb">addr-spec</spanx> form (for example, may not contain an @ symbol).
</t>
<t>For example, the following <spanx style="verb">address-list</spanx> string:
</t>

<figure align="center"><artwork align="center">
"  James Smythe" &lt;james@example.com&gt;, Friends:
  jane@example.com, =?UTF-8?Q?John_Sm=C3=AEth?=
  &lt;john@example.com&gt;;
</artwork></figure>
<t>would be parsed as:
</t>

<figure align="center"><artwork align="center">
[
  { "name": "James Smythe", "email": "james@example.com" },
  { "name": null, "email": "jane@example.com" },
  { "name": "John Smith", "email": "john@example.com" }
]
</artwork></figure>
<t>To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the following header fields:
</t>
<t>
<list style="symbols">
<t>From</t>
<t>Sender</t>
<t>Reply-To</t>
<t>To</t>
<t>Cc</t>
<t>Bcc</t>
<t>Resent-From</t>
<t>Resent-Sender</t>
<t>Resent-Reply-To</t>
<t>Resent-To</t>
<t>Resent-Cc</t>
<t>Resent-Bcc</t>
<t>Any header field not defined in <xref target="RFC5322"/> or <xref target="RFC2369"/></t>
</list>
</t>
</section>

<section anchor="groupedaddresses" title="GroupedAddresses">
<t>Type: <spanx style="verb">EmailAddressGroup[]</spanx>
</t>
<t>This is similar to the Addresses form but preserves group information. The header field is parsed as an <spanx style="verb">address-list</spanx> value, as specified in <xref target="RFC5322"/>, Section 3.4, into the <spanx style="verb">GroupedAddresses[]</spanx> type. Consecutive <spanx style="verb">mailbox</spanx> values that are not part of a group are still collected under an EmailAddressGroup object to provide a uniform type.
</t>
<t>An <spanx style="strong">EmailAddressGroup</spanx> object has the following properties:
</t>
<t>
<list style="symbols">
<t>name: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The <spanx style="verb">display-name</spanx> of the <spanx style="verb">group</spanx> <xref target="RFC5322"/>, or null if the addresses are not part of a group. If this is a <spanx style="verb">quoted-string</spanx>, it is processed the same as the <spanx style="verb">name</spanx> in the EmailAddress type.</t>

<t>addresses: <spanx style="verb">EmailAddress[]</spanx><vspace blankLines="1" />
The <spanx style="verb">mailbox</spanx> values that belong to this group, represented as EmailAddress
objects.</t>
</list>
</t>
<t>Any syntactically correct encoded sections <xref target="RFC2047"/> with a known encoding MUST be decoded, following the same rules as for the Text form (see <xref target="text"/>).
</t>
<t>Parsing SHOULD be best effort in the face of invalid structure to
accommodate invalid messages and semi-complete drafts.
</t>
<t>For example, the following <spanx style="verb">address-list</spanx> string:
</t>

<figure align="center"><artwork align="center">
"  James Smythe" &lt;james@example.com&gt;, Friends:
  jane@example.com, =?UTF-8?Q?John_Sm=C3=AEth?=
  &lt;john@example.com&gt;;
</artwork></figure>
<t>would be parsed as:
</t>

<figure align="center"><artwork align="center">
[
  { "name": null, "addresses": [
    { "name": "James Smythe", "email": "james@example.com" }
  ]},
  { "name": "Friends", "addresses": [
    { "name": null, "email": "jane@example.com" },
    { "name": "John Smith", "email": "john@example.com" }
  ]}
]
</artwork></figure>
<t>To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the same header fields as the Addresses form (see <xref target="addresses"/>).
</t>
</section>

<section anchor="messageids" title="MessageIds">
<t>Type: <spanx style="verb">String[]|null</spanx>
</t>
<t>The header field is parsed as a list of <spanx style="verb">msg-id</spanx> values, as specified in <xref target="RFC5322"/>, Section 3.6.4, into the <spanx style="verb">String[]</spanx> type. Comments and/or folding white space (CFWS) and surrounding angle brackets (<spanx style="verb">&lt;&gt;</spanx>) are removed. If parsing fails, the value is null.
</t>
<t>To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the following header fields:
</t>
<t>
<list style="symbols">
<t>Message-ID</t>
<t>In-Reply-To</t>
<t>References</t>
<t>Resent-Message-ID</t>
<t>Any header field not defined in <xref target="RFC5322"/> or <xref target="RFC2369"/></t>
</list>
</t>
</section>

<section anchor="date" title="Date">
<t>Type: <spanx style="verb">Date|null</spanx>
</t>
<t>The header field is parsed as a <spanx style="verb">date-time</spanx> value, as specified in <xref target="RFC5322"/>, Section 3.3, into the <spanx style="verb">Date</spanx> type. If parsing fails, the value is null.
</t>
<t>To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the following header fields:
</t>
<t>
<list style="symbols">
<t>Date</t>
<t>Resent-Date</t>
<t>Any header field not defined in <xref target="RFC5322"/> or <xref target="RFC2369"/></t>
</list>
</t>
</section>

<section anchor="urls" title="URLs">
<t>Type: <spanx style="verb">String[]|null</spanx>
</t>
<t>The header field is parsed as a list of URLs, as described in <xref target="RFC2369"/>, into the <spanx style="verb">String[]</spanx> type. Values do not include the surrounding angle brackets or any comments in the header field with the URLs. If parsing fails, the value is null.
</t>
<t>To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the following header fields:
</t>
<t>
<list style="symbols">
<t>List-Help</t>
<t>List-Unsubscribe</t>
<t>List-Subscribe</t>
<t>List-Post</t>
<t>List-Owner</t>
<t>List-Archive</t>
<t>Any header field not defined in <xref target="RFC5322"/> or <xref target="RFC2369"/></t>
</list>
</t>
</section>
</section>

<section anchor="header-fields-properties" title="Header Fields Properties">
<t>The following low-level Email property is specified for complete access to the header data of the message:
</t>
<t>
<list style="symbols">
<t>headers: <spanx style="verb">EmailHeader[]</spanx> (immutable)<vspace blankLines="1" />
This is a list of all header fields <xref target="RFC5322"/>, in the same order they appear in the message. An <spanx style="strong">EmailHeader</spanx> object has the following properties:
<list style="symbols">
<t>name: <spanx style="verb">String</spanx><vspace blankLines="1" />
The header <spanx style="verb">field name</spanx> as defined in <xref target="RFC5322"/>, with the same capitalization that it has in the message.</t>

<t>value: <spanx style="verb">String</spanx><vspace blankLines="1" />
The header <spanx style="verb">field value</spanx> as defined in <xref target="RFC5322"/>, in Raw form.</t>
</list></t>
</list>
</t>
<t>In addition, the client may request/send properties representing individual header fields of the form:
</t>

<figure align="center"><artwork align="center">
header:{header-field-name}
</artwork></figure>
<t>Where <spanx style="verb">{header-field-name}</spanx> means any series of one or more printable ASCII characters (i.e., characters that have values between 33 and 126, inclusive), except for colon (:). The property may also have the following suffixes:
</t>
<t>
<list style="symbols">
<t>:as{header-form}<vspace blankLines="1" />
This means the value is in a parsed form, where <spanx style="verb">{header-form}</spanx> is one of the parsed-form names specified above. If not given, the value is in Raw form.</t>

<t>:all<vspace blankLines="1" />
This means the value is an array, with the items corresponding to each instance of the header field, in the order they appear in the message. If this suffix is not used, the result is the value of the <spanx style="strong">last</spanx> instance of the header field (i.e., identical to the last item in the array if :all is used), or null if none.</t>
</list>
</t>
<t>If both suffixes are used, they MUST be specified in the order above. Header field names are matched case insensitively. The value is typed according to the requested form or to an array of that type if :all is used.

If no header fields exist in the message with the requested name, the value is null if fetching a single instance or an empty array if requesting :all.
</t>
<t>As a simple example, if the client requests a property called <spanx style="verb">header:subject</spanx>, this means find the <spanx style="strong">last</spanx> header field in the message named &quot;subject&quot; (matched case insensitively) and return the value in Raw form, or null if no header field of this name is found.
</t>
<t>For a more complex example, consider the client requesting a property called <spanx style="verb">header:Resent-To:asAddresses:all</spanx>. This means:
</t>
<t>
<list style="numbers">
<t>Find <spanx style="strong">all</spanx> header fields named Resent-To (matched case insensitively).</t>
<t>For each instance, parse the header field value in the Addresses form.</t>
<t>The result is of type <spanx style="verb">EmailAddress[][]</spanx> -- each item in the array
corresponds to the parsed value (which is itself an array) of the Resent-To
header field instance.</t>
</list>
</t>
<t>The following convenience properties are also specified for the Email object:
</t>
<t>
<list style="symbols">
<t>messageId: <spanx style="verb">String[]|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:Message-ID:asMessageIds</spanx>.  For messages conforming to RFC 5322, this will be an array with a single entry.</t>

<t>inReplyTo: <spanx style="verb">String[]|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:In-Reply-To:asMessageIds</spanx>.</t>

<t>references: <spanx style="verb">String[]|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:References:asMessageIds</spanx>.</t>

<t>sender: <spanx style="verb">EmailAddress[]|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:Sender:asAddresses</spanx>.</t>

<t>from: <spanx style="verb">EmailAddress[]|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:From:asAddresses</spanx>.</t>

<t>to: <spanx style="verb">EmailAddress[]|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:To:asAddresses</spanx>.</t>

<t>cc: <spanx style="verb">EmailAddress[]|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:Cc:asAddresses</spanx>.</t>

<t>bcc: <spanx style="verb">EmailAddress[]|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:Bcc:asAddresses</spanx>.</t>

<t>replyTo: <spanx style="verb">EmailAddress[]|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:Reply-To:asAddresses</spanx>.</t>

<t>subject: <spanx style="verb">String|null</spanx> (immutable)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:Subject:asText</spanx>.</t>

<t>sentAt: <spanx style="verb">Date|null</spanx> (immutable; default on creation: current server time)<vspace blankLines="1" />
The value is identical to the value of <spanx style="verb">header:Date:asDate</spanx>.</t>
</list>
</t>
</section>

<section anchor="body-parts" title="Body Parts">
<t>These properties are derived from the message body <xref target="RFC5322"/> and its MIME entities <xref target="RFC2045"/>.
</t>
<t>An <spanx style="strong">EmailBodyPart</spanx> object has the following properties:
</t>
<t>
<list style="symbols">
<t>partId: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
Identifies this part uniquely within the Email. This is scoped to the <spanx style="verb">emailId</spanx> and has no meaning outside of the JMAP Email object representation. This is null if, and only if, the part is of type <spanx style="verb">multipart/*</spanx>.</t>

<t>blobId: <spanx style="verb">Id|null</spanx><vspace blankLines="1" />
The id representing the raw octets of the contents of the part, after decoding any known Content-Transfer-Encoding (as defined in <xref target="RFC2045"/>), or null if, and only if, the part is of type <spanx style="verb">multipart/*</spanx>. Note that two parts may be transfer-encoded differently but have the same blob id if their decoded octets are identical and the server is using a secure hash of the data for the blob id. If the transfer encoding is unknown, it is treated as though it had no transfer encoding.</t>

<t>size: <spanx style="verb">UnsignedInt</spanx><vspace blankLines="1" />
The size, in octets, of the raw data after content transfer decoding (as referenced by the <spanx style="verb">blobId</spanx>, i.e., the number of octets in the file the user would download).</t>

<t>headers: <spanx style="verb">EmailHeader[]</spanx><vspace blankLines="1" />
This is a list of all header fields in the part, in the order they appear in the message. The values are in Raw form.</t>

<t>name: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
This is the decoded <spanx style="verb">filename</spanx> parameter of the Content-Disposition header field per <xref target="RFC2231"/>, or (for compatibility with existing systems) if not present, then it's the decoded <spanx style="verb">name</spanx> parameter of the Content-Type header field per <xref target="RFC2047"/>.</t>

<t>type: <spanx style="verb">String</spanx><vspace blankLines="1" />
The value of the Content-Type header field of the part, if present; otherwise, the implicit type as per the MIME standard (<spanx style="verb">text/plain</spanx> or <spanx style="verb">message/rfc822</spanx> if inside a <spanx style="verb">multipart/digest</spanx>). CFWS is removed and any parameters are stripped.</t>

<t>charset: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The value of the charset parameter of the Content-Type header field, if present, or null if the header field is present but not of type <spanx style="verb">text/*</spanx>. If there is no Content-Type header field, or it exists and is of type <spanx style="verb">text/*</spanx> but has no charset parameter, this is the implicit charset as per the MIME standard: <spanx style="verb">us-ascii</spanx>.</t>

<t>disposition: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The value of the Content-Disposition header field of the part, if present; otherwise, it's null. CFWS is removed and any parameters are stripped.</t>

<t>cid: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The value of the Content-Id header field of the part, if present; otherwise, it's null. CFWS and surrounding angle brackets (<spanx style="verb">&lt;&gt;</spanx>) are removed. This may be used to reference the content from within a <spanx style="verb">text/html</spanx> body part <xref target="HTML"/> using the <spanx style="verb">cid:</spanx> protocol, as defined in <xref target="RFC2392"/>.</t>

<t>language: <spanx style="verb">String[]|null</spanx><vspace blankLines="1" />
The list of language tags, as defined in <xref target="RFC3282"/>, in the Content-Language header field of the part, if present.</t>

<t>location: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The URI, as defined in <xref target="RFC2557"/>, in the Content-Location header field of the part, if present.</t>

<t>subParts: <spanx style="verb">EmailBodyPart[]|null</spanx><vspace blankLines="1" />
If the type is <spanx style="verb">multipart/*</spanx>, this contains the body parts of each child.</t>
</list>
</t>
<t>In addition, the client may request/send EmailBodyPart properties representing individual header fields, following the same syntax and semantics as for the Email object, e.g., <spanx style="verb">header:Content-Type</spanx>.
</t>
<t>The following Email properties are specified for access to the body data of the message:
</t>
<t>
<list style="symbols">
<t>bodyStructure: <spanx style="verb">EmailBodyPart</spanx> (immutable)<vspace blankLines="1" />
This is the full MIME structure of the message body, without recursing into <spanx style="verb">message/rfc822</spanx> or <spanx style="verb">message/global</spanx> parts. Note that EmailBodyParts may have subParts if they are of type <spanx style="verb">multipart/*</spanx>.</t>

<t>bodyValues: <spanx style="verb">String[EmailBodyValue]</spanx> (immutable)<vspace blankLines="1" />
This is a map of <spanx style="verb">partId</spanx> to an EmailBodyValue object for none, some, or all <spanx style="verb">text/*</spanx> parts. Which parts are included and whether the value is truncated is determined by various arguments to <spanx style="verb">Email/get</spanx> and <spanx style="verb">Email/parse</spanx>.
An <spanx style="strong">EmailBodyValue</spanx> object has the following properties:
<list style="symbols">
<t>value: <spanx style="verb">String</spanx><vspace blankLines="1" />
The value of the body part after decoding Content-Transfer-Encoding and
the Content-Type charset, if both known to the server, and with any CRLF replaced with a single LF. The server MAY use heuristics to determine the charset to use for decoding if the charset is unknown, no charset is given, or it believes the charset given is incorrect.

Decoding is best effort; the server SHOULD insert the unicode replacement character (U+FFFD) and continue when a malformed section is encountered.
<vspace blankLines="1" />
Note that due to the charset decoding and line ending normalisation, the length of this string will probably not be exactly the same as the <spanx style="verb">size</spanx> property on the corresponding EmailBodyPart.</t>

<t>isEncodingProblem: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
This is true if malformed sections were found while decoding the charset, the charset was unknown, or the content-transfer-encoding was unknown.</t>

<t>isTruncated: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
This is true if the <spanx style="verb">value</spanx> has been truncated.</t>
</list>

See the Security Considerations section for issues related to truncation
and heuristic determination of the content-type and charset.</t>

<t>textBody: <spanx style="verb">EmailBodyPart[]</spanx> (immutable)<vspace blankLines="1" />
A list of <spanx style="verb">text/plain</spanx>, <spanx style="verb">text/html</spanx>, <spanx style="verb">image/*</spanx>, <spanx style="verb">audio/*</spanx>, and/or <spanx style="verb">video/*</spanx> parts to display (sequentially) as the message body, with a preference for <spanx style="verb">text/plain</spanx> when alternative versions are available.</t>

<t>htmlBody: <spanx style="verb">EmailBodyPart[]</spanx> (immutable)<vspace blankLines="1" />
A list of <spanx style="verb">text/plain</spanx>, <spanx style="verb">text/html</spanx>, <spanx style="verb">image/*</spanx>, <spanx style="verb">audio/*</spanx>, and/or <spanx style="verb">video/*</spanx> parts to display (sequentially) as the message body, with a preference for <spanx style="verb">text/html</spanx> when alternative versions are available.</t>

<t>attachments: <spanx style="verb">EmailBodyPart[]</spanx> (immutable)<vspace blankLines="1" />
A list, traversing depth-first, of all parts in <spanx style="verb">bodyStructure</spanx> that satisfy either of the following conditions:
<list style="symbols">
<t>not of type <spanx style="verb">multipart/*</spanx> and not included in <spanx style="verb">textBody</spanx> or <spanx style="verb">htmlBody</spanx></t>

<t>of type <spanx style="verb">image/*</spanx>, <spanx style="verb">audio/*</spanx>, or <spanx style="verb">video/*</spanx> and not in both <spanx style="verb">textBody</spanx> and
<spanx style="verb">htmlBody</spanx></t>
</list>

None of these parts include subParts, including <spanx style="verb">message/*</spanx> types. Attached messages may be fetched using the <spanx style="verb">Email/parse</spanx> method and the <spanx style="verb">blobId</spanx>.
<vspace blankLines="1" />
Note that a <spanx style="verb">text/html</spanx> body part <xref target="HTML"/> may reference image parts in attachments by using <spanx style="verb">cid:</spanx> links to reference the Content-Id, as defined in <xref target="RFC2392"/>, or by referencing the Content-Location.</t>

<t>hasAttachment: <spanx style="verb">Boolean</spanx> (immutable; server-set)<vspace blankLines="1" />
This is true if there are one or more parts in the message that a client UI should offer as downloadable. A server SHOULD set hasAttachment to true if the <spanx style="verb">attachments</spanx> list contains at least one item that does not have <spanx style="verb">Content-Disposition: inline</spanx>. The server MAY ignore parts in this list that are processed automatically in some way or are referenced as embedded images in one of the <spanx style="verb">text/html</spanx> parts of the message.
<vspace blankLines="1" />
The server MAY set hasAttachment based on implementation-defined or site-configurable heuristics.</t>

<t>preview: <spanx style="verb">String</spanx> (immutable; server-set)<vspace blankLines="1" />
A plaintext fragment of the message body. This is intended to be shown as a preview line when listing messages in the mail store and may be truncated when shown. The server may choose which part of the message to include in the preview; skipping quoted sections and salutations and collapsing white space can result in a more useful preview.
<vspace blankLines="1" />
This MUST NOT be more than 256 characters in length.
<vspace blankLines="1" />
As this is derived from the message content by the server, and the algorithm for doing so could change over time, fetching this for an Email a second time MAY return a different result. However, the previous value is not considered incorrect, and the change SHOULD NOT cause the Email object to be considered as changed by the server.</t>
</list>
</t>
<t>The exact algorithm for decomposing bodyStructure into textBody, htmlBody, and attachments part lists is not mandated, as this is a quality-of-service implementation issue and likely to require workarounds for malformed content discovered over time. However, the following algorithm (expressed here in JavaScript) is suggested as a starting point, based on real-world experience:
</t>

<figure align="center"><artwork align="center">
function isInlineMediaType ( type ) {
  return type.startsWith( 'image/' ) ||
         type.startsWith( 'audio/' ) ||
         type.startsWith( 'video/' );
}

function parseStructure ( parts, multipartType, inAlternative,
        htmlBody, textBody, attachments ) {

    // For multipartType == alternative
    let textLength = textBody ? textBody.length : -1;
    let htmlLength = htmlBody ? htmlBody.length : -1;

    for ( let i = 0; i &lt; parts.length; i += 1 ) {
        let part = parts[i];
        let isMultipart = part.type.startsWith( 'multipart/' );
        // Is this a body part rather than an attachment
        let isInline = part.disposition != "attachment" &amp;&amp;
            // Must be one of the allowed body types
            ( part.type == "text/plain" ||
              part.type == "text/html" ||
              isInlineMediaType( part.type ) ) &amp;&amp;
            // If multipart/related, only the first part can be inline
            // If a text part with a filename, and not the first item
            // in the multipart, assume it is an attachment
            ( i === 0 ||
              ( multipartType != "related" &amp;&amp;
                ( isInlineMediaType( part.type ) || !part.name ) ) );

        if ( isMultipart ) {
            let subMultiType = part.type.split( '/' )[1];
            parseStructure( part.subParts, subMultiType,
                inAlternative || ( subMultiType == 'alternative' ),
                htmlBody, textBody, attachments );
        } else if ( isInline ) {
            if ( multipartType == 'alternative' ) {
                switch ( part.type ) {
                case 'text/plain':
                    textBody.push( part );
                    break;
                case 'text/html':
                    htmlBody.push( part );
                    break;
                default:
                    attachments.push( part );
                    break;
                }
                continue;
            } else if ( inAlternative ) {
                if ( part.type == 'text/plain' ) {
                    htmlBody = null;
                }
                if ( part.type == 'text/html' ) {
                    textBody = null;
                }
            }
            if ( textBody ) {
                textBody.push( part );
            }
            if ( htmlBody ) {
                htmlBody.push( part );
            }
            if ( ( !textBody || !htmlBody ) &amp;&amp;
                    isInlineMediaType( part.type ) ) {
                attachments.push( part );
            }
        } else {
            attachments.push( part );
        }
    }

    if ( multipartType == 'alternative' &amp;&amp; textBody &amp;&amp; htmlBody ) {
        // Found HTML part only
        if ( textLength == textBody.length &amp;&amp;
                htmlLength != htmlBody.length ) {
            for ( let i = htmlLength; i &lt; htmlBody.length; i += 1 ) {
                textBody.push( htmlBody[i] );
            }
        }
        // Found plaintext part only
        if ( htmlLength == htmlBody.length &amp;&amp;
                textLength != textBody.length ) {
            for ( let i = textLength; i &lt; textBody.length; i += 1 ) {
                htmlBody.push( textBody[i] );
            }
        }
    }
}

// Usage:
let htmlBody = [];
let textBody = [];
let attachments = [];

parseStructure( [ bodyStructure ], 'mixed', false,
    htmlBody, textBody, attachments );
</artwork></figure>
<t>For instance, consider a message with both text and HTML versions that has
gone through a list software manager that attaches a header and footer. It might have a MIME structure something like:
</t>

<figure align="center"><artwork align="center">
multipart/mixed
  text/plain, content-disposition=inline - A
  multipart/mixed
    multipart/alternative
      multipart/mixed
        text/plain, content-disposition=inline - B
        image/jpeg, content-disposition=inline - C
        text/plain, content-disposition=inline - D
      multipart/related
        text/html - E
        image/jpeg - F
    image/jpeg, content-disposition=attachment - G
    application/x-excel - H
    message/rfc822 - J
  text/plain, content-disposition=inline - K
</artwork></figure>
<t>In this case, the above algorithm would decompose this to:
</t>

<figure align="center"><artwork align="center">
textBody =&gt; [ A, B, C, D, K ]
htmlBody =&gt; [ A, E, K ]
attachments =&gt; [ C, F, G, H, J ]
</artwork></figure>
</section>
</section>

<section anchor="emailget" title="Email/get">
<t>This is a standard &quot;/get&quot; method as described in <xref target="RFC8620"/>, Section 5.1 with the following additional request arguments:
</t>
<t>
<list style="symbols">
<t>bodyProperties: <spanx style="verb">String[]</spanx><vspace blankLines="1" />
A list of properties to fetch for each EmailBodyPart returned. If omitted, this defaults to:

<figure align="center"><artwork align="center">
[ "partId", "blobId", "size", "name", "type", "charset",
  "disposition", "cid", "language", "location" ]
</artwork></figure></t>
<t>fetchTextBodyValues: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
If true, the <spanx style="verb">bodyValues</spanx> property includes any <spanx style="verb">text/*</spanx> part in the <spanx style="verb">textBody</spanx> property.</t>

<t>fetchHTMLBodyValues: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
If true, the <spanx style="verb">bodyValues</spanx> property includes any <spanx style="verb">text/*</spanx> part in the <spanx style="verb">htmlBody</spanx> property.</t>

<t>fetchAllBodyValues: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
If true, the <spanx style="verb">bodyValues</spanx> property includes any <spanx style="verb">text/*</spanx> part in the <spanx style="verb">bodyStructure</spanx> property.</t>

<t>maxBodyValueBytes: <spanx style="verb">UnsignedInt</spanx> (default: 0)<vspace blankLines="1" />
If greater than zero, the <spanx style="verb">value</spanx> property of any EmailBodyValue object returned in <spanx style="verb">bodyValues</spanx> MUST be truncated if necessary so it does not exceed this number of octets in size. If 0 (the default), no truncation occurs.
<vspace blankLines="1" />
The server MUST ensure the truncation results in valid UTF-8 and does not occur mid-codepoint. If the part is of type <spanx style="verb">text/html</spanx>, the server SHOULD NOT truncate inside an HTML tag, e.g., in the middle of <spanx style="verb">&lt;a href="https://example.com"&gt;</spanx>. There is no requirement for the truncated form to be a balanced tree or valid HTML (indeed, the original source may well be neither of these things).</t>
</list>
</t>
<t>If the standard <spanx style="verb">properties</spanx> argument is omitted or null, the following default MUST be used instead of &quot;all&quot; properties:
</t>

<figure align="center"><artwork align="center">
[ "id", "blobId", "threadId", "mailboxIds", "keywords", "size",
"receivedAt", "messageId", "inReplyTo", "references", "sender", "from",
"to", "cc", "bcc", "replyTo", "subject", "sentAt", "hasAttachment",
"preview", "bodyValues", "textBody", "htmlBody", "attachments" ]
</artwork></figure>
<t>The following properties are expected to be fast to fetch in a quality implementation:
</t>
<t>
<list style="symbols">
<t>id</t>
<t>blobId</t>
<t>threadId</t>
<t>mailboxIds</t>
<t>keywords</t>
<t>size</t>
<t>receivedAt</t>
<t>messageId</t>
<t>inReplyTo</t>
<t>sender</t>
<t>from</t>
<t>to</t>
<t>cc</t>
<t>bcc</t>
<t>replyTo</t>
<t>subject</t>
<t>sentAt</t>
<t>hasAttachment</t>
<t>preview</t>
</list>
</t>
<t>Clients SHOULD take care when fetching any other properties, as there may be significantly longer latency in fetching and returning the data.
</t>
<t>As specified above, parsed forms of headers may only be used on appropriate header fields. Attempting to fetch a form that is forbidden (e.g., <spanx style="verb">header:From:asDate</spanx>) MUST result in the method call being rejected with an <spanx style="verb">invalidArguments</spanx> error.
</t>
<t>Where a specific header field is requested as a property, the capitalization of the property name in the response MUST be identical to that used in the request.
</t>

<section anchor="example-3" title="Example">
<t>Request:
</t>

<figure align="center"><artwork align="center">
[[ "Email/get", {
  "ids": [ "f123u456", "f123u457" ],
  "properties": [ "threadId", "mailboxIds", "from", "subject",
    "receivedAt", "header:List-POST:asURLs",
    "htmlBody", "bodyValues" ],
  "bodyProperties": [ "partId", "blobId", "size", "type" ],
  "fetchHTMLBodyValues": true,
  "maxBodyValueBytes": 256
}, "#1" ]]
</artwork></figure>
<t>and response:
</t>

<figure align="center"><artwork align="center">
[[ "Email/get", {
  "accountId": "abc",
  "state": "41234123231",
  "list": [
    {
      "id": "f123u457",
      "threadId": "ef1314a",
      "mailboxIds": { "f123": true },
      "from": [{ "name": "Joe Bloggs", "email": "joe@example.com" }],
      "subject": "Dinner on Thursday?",
      "receivedAt": "2013-10-13T14:12:00Z",
      "header:List-POST:asURLs": [
        "mailto:partytime@lists.example.com"
      ],
      "htmlBody": [{
        "partId": "1",
        "blobId": "B841623871",
        "size": 283331,
        "type": "text/html"
      }, {
        "partId": "2",
        "blobId": "B319437193",
        "size": 10343,
        "type": "text/plain"
      }],
      "bodyValues": {
        "1": {
          "isEncodingProblem": false,
          "isTruncated": true,
          "value": "&lt;html&gt;&lt;body&gt;&lt;p&gt;Hello ..."
        },
        "2": {
          "isEncodingProblem": false,
          "isTruncated": false,
          "value": "-- Sent by your friendly mailing list ..."
        }
      }
    }
  ],
  "notFound": [ "f123u456" ]
}, "#1" ]]
</artwork></figure>
</section>
</section>

<section anchor="emailchanges" title="Email/changes">
<t>This is a standard &quot;/changes&quot; method as described in <xref target="RFC8620"/>, Section 5.2. If generating intermediate states for a large set of changes, it is recommended that newer changes be returned first, as these are generally of more interest to users.
</t>
</section>

<section anchor="emailquery" title="Email/query">
<t>This is a standard &quot;/query&quot; method as described in <xref target="RFC8620"/>, Section 5.5 but with the following additional request arguments:
</t>
<t>
<list style="symbols">
<t>collapseThreads: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
If true, Emails in the same Thread as a previous Email in the list (given the filter and sort order) will be removed from the list. This means only one Email at most will be included in the list for any given Thread.</t>
</list>
</t>
<t>In quality implementations, the query <spanx style="verb">total</spanx> property is expected to be fast to calculate when the filter consists solely of a single <spanx style="verb">inMailbox</spanx> property, as it is the same as the totalEmails or totalThreads properties (depending on whether collapseThreads is true) of the associated Mailbox object.
</t>

<section anchor="filtering" title="Filtering">
<t>A <spanx style="strong">FilterCondition</spanx> object has the following properties, any of which may be omitted:
</t>
<t>
<list style="symbols">
<t>inMailbox: <spanx style="verb">Id</spanx><vspace blankLines="1" />
A Mailbox id. An Email must be in this Mailbox to match the condition.</t>

<t>inMailboxOtherThan: <spanx style="verb">Id[]</spanx><vspace blankLines="1" />
A list of Mailbox ids. An Email must be in at least one Mailbox not in this list to match the condition. This is to allow messages solely in trash/spam to be easily excluded from a search.</t>

<t>before: <spanx style="verb">UTCDate</spanx><vspace blankLines="1" />
The <spanx style="verb">receivedAt</spanx> date-time of the Email must be before this date-time to match the condition.</t>

<t>after: <spanx style="verb">UTCDate</spanx><vspace blankLines="1" />
The <spanx style="verb">receivedAt</spanx> date-time of the Email must be the same or after this date-time to match the condition.</t>

<t>minSize: <spanx style="verb">UnsignedInt</spanx><vspace blankLines="1" />
The <spanx style="verb">size</spanx> property of the Email must be equal to or greater than this number to match the condition.</t>

<t>maxSize: <spanx style="verb">UnsignedInt</spanx><vspace blankLines="1" />
The <spanx style="verb">size</spanx> property of the Email must be less than this number to match the condition.</t>

<t>allInThreadHaveKeyword: <spanx style="verb">String</spanx><vspace blankLines="1" />
All Emails (including this one) in the same Thread as this Email must have the given keyword to match the condition.</t>

<t>someInThreadHaveKeyword: <spanx style="verb">String</spanx><vspace blankLines="1" />
At least one Email (possibly this one) in the same Thread as this Email must have the given keyword to match the condition.</t>

<t>noneInThreadHaveKeyword: <spanx style="verb">String</spanx><vspace blankLines="1" />
All Emails (including this one) in the same Thread as this Email must <spanx style="strong">not</spanx> have the given keyword to match the condition.</t>

<t>hasKeyword: <spanx style="verb">String</spanx><vspace blankLines="1" />
This Email must have the given keyword to match the condition.</t>

<t>notKeyword: <spanx style="verb">String</spanx><vspace blankLines="1" />
This Email must not have the given keyword to match the condition.</t>

<t>hasAttachment: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
The <spanx style="verb">hasAttachment</spanx> property of the Email must be identical to the value given to match the condition.</t>

<t>text: <spanx style="verb">String</spanx><vspace blankLines="1" />
Looks for the text in Emails. The server MUST look up text in the From, To, Cc, Bcc, and Subject header fields of the message and SHOULD look inside any <spanx style="verb">text/*</spanx> or other body parts that may be converted to text by the server. The server MAY extend the search to any additional textual property.</t>

<t>from: <spanx style="verb">String</spanx><vspace blankLines="1" />
Looks for the text in the From header field of the message.</t>

<t>to: <spanx style="verb">String</spanx><vspace blankLines="1" />
Looks for the text in the To header field of the message.</t>

<t>cc: <spanx style="verb">String</spanx><vspace blankLines="1" />
Looks for the text in the Cc header field of the message.</t>

<t>bcc: <spanx style="verb">String</spanx><vspace blankLines="1" />
Looks for the text in the Bcc header field of the message.</t>

<t>subject: <spanx style="verb">String</spanx><vspace blankLines="1" />
Looks for the text in the Subject header field of the message.</t>

<t>body: <spanx style="verb">String</spanx><vspace blankLines="1" />
Looks for the text in one of the body parts of the message. The server MAY exclude MIME body parts with content media types other than <spanx style="verb">text/*</spanx> and <spanx style="verb">message/*</spanx> from consideration in search matching. Care should be taken to match based on the text content actually presented to an end user by viewers for that media type or otherwise identified as appropriate for search indexing. Matching document metadata uninteresting to an end user (e.g., markup tag and attribute names) is undesirable.</t>

<t>header: <spanx style="verb">String[]</spanx><vspace blankLines="1" />
The array MUST contain either one or two elements. The first element is the name of the header field to match against. The second (optional) element is the text to look for in the header field value. If not supplied, the message matches simply if it has a header field of the given name.</t>
</list>
</t>
<t>If zero properties are specified on the FilterCondition, the condition MUST always evaluate to true. If multiple properties are specified, ALL must apply for the condition to be true (it is equivalent to splitting the object into one-property conditions and making them all the child of an AND filter operator).
</t>
<t>The exact semantics for matching <spanx style="verb">String</spanx> fields is <spanx style="strong">deliberately not defined</spanx> to allow for flexibility in indexing implementation, subject to the following:
</t>
<t>
<list style="symbols">
<t>Any syntactically correct encoded sections <xref target="RFC2047"/> of header fields with a known encoding SHOULD be decoded before attempting to match text.</t>

<t>When searching inside a <spanx style="verb">text/html</spanx> body part, any text considered markup rather than content SHOULD be ignored, including HTML tags and most attributes, anything inside the <spanx style="verb">&lt;head&gt;</spanx> tag, Cascading Style Sheets (CSS), and JavaScript. Attribute content intended for presentation to the user such as &quot;alt&quot; and &quot;title&quot; SHOULD be considered in the search.</t>

<t>Text SHOULD be matched in a case-insensitive manner.</t>

<t>Text contained in either (but matched) single (') or double (") quotes SHOULD be treated as a <spanx style="strong">phrase search</spanx>; that is, a match is required for that exact word or sequence of words, excluding the surrounding quotation marks.
<vspace blankLines="1" />
Within a phrase, to match one of the following characters you MUST escape it by prefixing it with a backslash (\):
<figure align="center"><artwork align="center">
  ' " \
</artwork></figure>
</t>

<t>Outside of a phrase, white space SHOULD be treated as dividing separate tokens that may be searched for separately but MUST all be present for the Email to match the filter.</t>

<t>Tokens (not part of a phrase) MAY be matched on a whole-word basis using stemming (for example, a text search for &quot;bus&quot; would match &quot;buses&quot; but not &quot;business&quot;).</t>
</list>
</t>
</section>

<section anchor="sorting" title="Sorting">
<t>The following value for the <spanx style="verb">property</spanx> field on the Comparator object MUST be supported for sorting:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">receivedAt</spanx> - The <spanx style="verb">receivedAt</spanx> date as returned in the Email object.</t>
</list>
</t>
<t>The following values for the <spanx style="verb">property</spanx> field on the Comparator object SHOULD be supported for sorting. When specifying a &quot;hasKeyword&quot;, &quot;allInThreadHaveKeyword&quot;, or &quot;someInThreadHaveKeyword&quot; sort, the Comparator object MUST also have a <spanx style="verb">keyword</spanx> property.
</t>
<t>
<list style="symbols">
<t><spanx style="verb">size</spanx> - The <spanx style="verb">size</spanx> as returned in the Email object.</t>

<t><spanx style="verb">from</spanx> - This is taken to be either the <spanx style="verb">name</spanx> property or if null/empty, the <spanx style="verb">email</spanx> property of the <spanx style="strong">first</spanx> EmailAddress object in the Email's <spanx style="verb">from</spanx> property. If still none, consider the value to be the empty string.</t>

<t><spanx style="verb">to</spanx> - This is taken to be either the <spanx style="verb">name</spanx> property or if null/empty, the <spanx style="verb">email</spanx> property of the <spanx style="strong">first</spanx> EmailAddress object in the Email's <spanx style="verb">to</spanx> property. If still none, consider the value to be the empty string.</t>

<t><spanx style="verb">subject</spanx> - This is taken to be the base subject of the message, as defined in Section 2.1 of <xref target="RFC5256"/>.</t>

<t><spanx style="verb">sentAt</spanx> - The <spanx style="verb">sentAt</spanx> property on the Email object.</t>
<t><spanx style="verb">hasKeyword</spanx> - This value MUST be considered true if the Email has the keyword given as an additional <spanx style="verb">keyword</spanx> property on the Comparator object, or false otherwise.</t>

<t><spanx style="verb">allInThreadHaveKeyword</spanx> - This value MUST be considered true for the Email if <spanx style="strong">all</spanx> of the Emails in the same Thread have the keyword given as an additional <spanx style="verb">keyword</spanx> property on the Comparator object.</t>

<t><spanx style="verb">someInThreadHaveKeyword</spanx> - This value MUST be considered true for the Email if <spanx style="strong">any</spanx> of the Emails in the same Thread have the keyword given as an additional <spanx style="verb">keyword</spanx> property on the Comparator object.</t>
</list>
</t>
<t>The server MAY support sorting based on other properties as well. A client can discover which properties are supported by inspecting the account's <spanx style="verb">capabilities</spanx> object (see <xref target="additions-to-the-capabilities-object"/>).
</t>
<t>Example sort:
</t>

<figure align="center"><artwork align="center">
[{
  "property": "someInThreadHaveKeyword",
  "keyword": "$flagged",
  "isAscending": false
}, {
  "property": "subject",
  "collation": "i;ascii-casemap"
}, {
  "property": "receivedAt",
  "isAscending": false
}]
</artwork></figure>
<t>This would sort Emails in flagged Threads first (the Thread is considered flagged if any Email within it is flagged), in subject order second, and then from newest first for messages with the same subject. If two Emails have identical values for all three properties, then the order is server dependent but must be stable.
</t>
</section>

<section anchor="thread-collapsing" title="Thread Collapsing">
<t>When <spanx style="verb">collapseThreads</spanx> is true, then after filtering and sorting the Email list, the list is further winnowed by removing any Emails for a Thread id that has already been seen (when passing through the list sequentially). A Thread will therefore only appear <spanx style="strong">once</spanx> in the result, at the position of the first Email in the list that belongs to the Thread (given the current sort/filter).
</t>
</section>
</section>

<section anchor="emailquerychanges" title="Email/queryChanges">
<t>This is a standard &quot;/queryChanges&quot; method as described in <xref target="RFC8620"/>, Section 5.6 with the following additional request argument:
</t>
<t>
<list style="symbols">
<t>collapseThreads: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
The <spanx style="verb">collapseThreads</spanx> argument that was used with <spanx style="verb">Email/query</spanx>.</t>
</list>
</t>
</section>

<section anchor="emailset" title="Email/set">
<t>This is a standard &quot;/set&quot; method as described in <xref target="RFC8620"/>, Section 5.3. The <spanx style="verb">Email/set</spanx> method encompasses:
</t>
<t>
<list style="symbols">
<t>Creating a draft</t>
<t>Changing the keywords of an Email (e.g., unread/flagged status)</t>
<t>Adding/removing an Email to/from Mailboxes (moving a message)</t>
<t>Deleting Emails</t>
</list>
</t>
<t>The format of the <spanx style="verb">keywords</spanx>/<spanx style="verb">mailboxIds</spanx> properties means that when updating an Email, you can either replace the entire set of keywords/Mailboxes (by setting the full value of the property) or add/remove individual ones using the JMAP patch syntax (see <xref target="RFC8620"/>, Section 5.3 for the specification and Section 5.7 for an example).
</t>
<t>Due to the format of the Email object, when creating an Email, there are a
number of ways to specify the same information. To ensure that the message <xref target="RFC5322"/> to
create is unambiguous, the following constraints apply to Email
objects submitted for creation:
</t>
<t>
<list style="symbols">
<t>The <spanx style="verb">headers</spanx> property MUST NOT be given on either the top-level Email or an
EmailBodyPart -- the client must set each header field as an individual property.</t>

<t>There MUST NOT be two properties that represent the same header field
(e.g., <spanx style="verb">header:from</spanx> and <spanx style="verb">from</spanx>) within the Email or particular EmailBodyPart.</t>
<t>Header fields MUST NOT be specified in parsed forms that are forbidden for
that particular field.</t>

<t>Header fields beginning with <spanx style="verb">Content-</spanx> MUST NOT be specified on the Email object,
only on EmailBodyPart objects.</t>

<t>If a <spanx style="verb">bodyStructure</spanx> property is given, there MUST NOT be <spanx style="verb">textBody</spanx>, <spanx style="verb">htmlBody</spanx>, or
<spanx style="verb">attachments</spanx> properties.</t>

<t>If given, the <spanx style="verb">bodyStructure</spanx> EmailBodyPart MUST NOT contain a property
representing a header field that is already defined on the top-level Email
object.</t>

<t>If given, textBody MUST contain exactly one body part and it MUST be of type <spanx style="verb">text/plain</spanx>.</t>
<t>If given, htmlBody MUST contain exactly one body part and it MUST be of type <spanx style="verb">text/html</spanx>.</t>
<t>Within an EmailBodyPart:
<list style="symbols">
<t>The client may specify a partId OR a blobId, but not both. If a partId is
given, this partId MUST be present in the <spanx style="verb">bodyValues</spanx> property.</t>

<t>The <spanx style="verb">charset</spanx> property MUST be omitted if a partId is given (the part's
content is included in bodyValues, and the server may choose any appropriate
encoding).</t>

<t>The <spanx style="verb">size</spanx> property MUST be omitted if a partId is given. If a blobId is
given, it may be included but is ignored by the server (the size is
actually calculated from the blob content itself).</t>

<t>A Content-Transfer-Encoding header field MUST NOT be given.</t>
</list></t>
<t>Within an EmailBodyValue object, isEncodingProblem and isTruncated MUST be
either false or omitted.</t>
</list>
</t>
<t>Creation attempts that violate any of this SHOULD be rejected with an <spanx style="verb">invalidProperties</spanx> error; however, a server MAY choose to modify the Email (e.g., choose between conflicting headers, use a different content-encoding, etc.) to comply with its requirements instead.
</t>
<t>The server MAY also choose to set additional headers. If not included, the server MUST generate and set a Message-ID header field in conformance with <xref target="RFC5322"/>, Section 3.6.4 and a Date header field in conformance with Section 3.6.1.
</t>
<t>The final message generated may be invalid per RFC 5322. For example, if it is a half-finished draft, the To header field may have a value that does not conform to the required syntax for this header. The message will be checked for strict conformance when submitted for sending (see the EmailSubmission object description).
</t>
<t>Destroying an Email removes it from all Mailboxes to which it belonged. To  just delete an Email to trash, simply change the <spanx style="verb">mailboxIds</spanx> property, so it is now in the Mailbox with a <spanx style="verb">role</spanx> property equal to <spanx style="verb">trash</spanx>, and remove all other Mailbox ids.
</t>
<t>When emptying the trash, clients SHOULD NOT destroy Emails that are also in a Mailbox other than trash. For those Emails, they SHOULD just remove the trash Mailbox from the Email.
</t>
<t>For successfully created Email objects, the <spanx style="verb">created</spanx> response contains the <spanx style="verb">id</spanx>, <spanx style="verb">blobId</spanx>, <spanx style="verb">threadId</spanx>, and <spanx style="verb">size</spanx> properties of the object.
</t>
<t>The following extra SetError types are defined:
</t>
<t>For <spanx style="verb">create</spanx>:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">blobNotFound</spanx>: At least one blob id given for an EmailBodyPart doesn't
exist. An extra <spanx style="verb">notFound</spanx> property of type <spanx style="verb">Id[]</spanx> MUST be included in the SetError object containing every <spanx style="verb">blobId</spanx> referenced by an EmailBodyPart that could not be found on the server.</t>
</list>
</t>
<t>For <spanx style="verb">create</spanx> and <spanx style="verb">update</spanx>:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">tooManyKeywords</spanx>: The change to the Email's keywords would exceed a
server-defined maximum.</t>
<t><spanx style="verb">tooManyMailboxes</spanx>: The change to the set of Mailboxes that this Email is in would exceed a server-defined maximum.</t>
</list>
</t>
</section>

<section anchor="emailcopy" title="Email/copy">
<t>This is a standard &quot;/copy&quot; method as described in <xref target="RFC8620"/>, Section 5.4, except only the <spanx style="verb">mailboxIds</spanx>, <spanx style="verb">keywords</spanx>, and <spanx style="verb">receivedAt</spanx> properties may be set during the copy. This method cannot modify the message represented by the Email.
</t>
<t>The server MAY forbid two Email objects with identical message content <xref target="RFC5322"/>, or even just with the same Message-ID <xref target="RFC5322"/>, to coexist within an account; if the target account already has the Email, the copy will be rejected with a standard <spanx style="verb">alreadyExists</spanx> error.
</t>
<t>For successfully copied Email objects, the <spanx style="verb">created</spanx> response contains the <spanx style="verb">id</spanx>, <spanx style="verb">blobId</spanx>, <spanx style="verb">threadId</spanx>, and <spanx style="verb">size</spanx> properties of the new object.
</t>
</section>

<section anchor="emailimport" title="Email/import">
<t>The <spanx style="verb">Email/import</spanx> method adds messages  <xref target="RFC5322"/> to the set of Emails in an account. The server MUST support messages with Email Address Internationalization (EAI) headers <xref target="RFC6532"/>. The messages must first be uploaded as blobs using the standard upload mechanism. The method takes the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx><vspace blankLines="1" />
The id of the account to use.</t>

<t>ifInState: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
This is a state string as returned by the <spanx style="verb">Email/get</spanx> method. If supplied, the string must match the current state of the account referenced by the accountId; otherwise, the method will be aborted and a <spanx style="verb">stateMismatch</spanx> error returned. If null, any changes will be applied to the current state.</t>

<t>emails: <spanx style="verb">Id[EmailImport]</spanx><vspace blankLines="1" />
A map of creation id (client specified) to EmailImport objects.</t>
</list>
</t>
<t>An <spanx style="strong">EmailImport</spanx> object has the following properties:
</t>
<t>
<list style="symbols">
<t>blobId: <spanx style="verb">Id</spanx><vspace blankLines="1" />
The id of the blob containing the raw message <xref target="RFC5322"/>.</t>

<t>mailboxIds: <spanx style="verb">Id[Boolean]</spanx><vspace blankLines="1" />
The ids of the Mailboxes to assign this Email to. At least one Mailbox MUST be given.</t>

<t>keywords: <spanx style="verb">String[Boolean]</spanx> (default: {})<vspace blankLines="1" />
The keywords to apply to the Email.</t>

<t>receivedAt: <spanx style="verb">UTCDate</spanx> (default: time of most recent Received header, or time of import on server if none)<vspace blankLines="1" />
The <spanx style="verb">receivedAt</spanx> date to set on the Email.</t>
</list>
</t>
<t>Each Email to import is considered an atomic unit that may succeed or fail individually. Importing successfully creates a new Email object from the data referenced by the blobId and applies the given Mailboxes, keywords, and receivedAt date.
</t>
<t>The server MAY forbid two Email objects with the same exact content <xref target="RFC5322"/>, or even just with the same Message-ID <xref target="RFC5322"/>, to coexist within an account. In this case, it MUST reject attempts to import an Email considered to be a duplicate with an <spanx style="verb">alreadyExists</spanx> SetError. An <spanx style="verb">existingId</spanx> property of type <spanx style="verb">Id</spanx> MUST be included on the SetError object with the id of the existing Email. If duplicates are allowed, the newly created Email object MUST have a separate id and independent mutable properties to the existing object.
</t>
<t>If the <spanx style="verb">blobId</spanx>, <spanx style="verb">mailboxIds</spanx>, or <spanx style="verb">keywords</spanx> properties are invalid (e.g., missing, wrong type, id not found), the server MUST reject the import with an <spanx style="verb">invalidProperties</spanx> SetError.
</t>
<t>If the Email cannot be imported because it would take the account over quota, the import should be rejected with an <spanx style="verb">overQuota</spanx> SetError.
</t>
<t>If the blob referenced is not a valid message <xref target="RFC5322"/>, the server MAY modify the message to fix errors (such as removing NUL octets or fixing invalid headers). If it does this, the <spanx style="verb">blobId</spanx> on the response MUST represent the new representation and therefore be different to the <spanx style="verb">blobId</spanx> on the EmailImport object. Alternatively, the server MAY reject the import with an <spanx style="verb">invalidEmail</spanx> SetError.
</t>
<t>The response has the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx><vspace blankLines="1" />
The id of the account used for this call.</t>

<t>oldState: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The state string that would have been returned by <spanx style="verb">Email/get</spanx> on this account before making the requested changes, or null if the server doesn't know what the previous state string was.</t>

<t>newState: <spanx style="verb">String</spanx><vspace blankLines="1" />
The state string that will now be returned by <spanx style="verb">Email/get</spanx> on this account.</t>

<t>created: <spanx style="verb">Id[Email]|null</spanx><vspace blankLines="1" />
A map of the creation id to an object containing the <spanx style="verb">id</spanx>, <spanx style="verb">blobId</spanx>, <spanx style="verb">threadId</spanx>, and <spanx style="verb">size</spanx> properties for each successfully imported Email, or null if none.</t>

<t>notCreated: <spanx style="verb">Id[SetError]|null</spanx><vspace blankLines="1" />
A map of the creation id to a SetError object for each Email that failed to be created, or null if all successful. The possible errors are defined above.</t>
</list>
</t>
<t>The following additional errors may be returned instead of the <spanx style="verb">Email/import</spanx> response:
</t>
<t><spanx style="verb">stateMismatch</spanx>: An <spanx style="verb">ifInState</spanx> argument was supplied, and it does not match the current state.
</t>
</section>

<section anchor="emailparse" title="Email/parse">
<t>This method allows you to parse blobs as messages <xref target="RFC5322"/> to get Email objects. The server MUST support messages with EAI headers <xref target="RFC6532"/>. This can be used to parse and display attached messages without having to import them as top-level Email objects in the mail store in their own right.
</t>
<t>The following metadata properties on the Email objects will be null if requested:
</t>
<t>
<list style="symbols">
<t>id</t>
<t>mailboxIds</t>
<t>keywords</t>
<t>receivedAt</t>
</list>
</t>
<t>The <spanx style="verb">threadId</spanx> property of the Email MAY be present if the server can calculate which Thread the Email would be assigned to were it to be imported. Otherwise, this too is null if fetched.
</t>
<t>The <spanx style="verb">Email/parse</spanx> method takes the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx><vspace blankLines="1" />
The id of the account to use.</t>

<t>blobIds: <spanx style="verb">Id[]</spanx><vspace blankLines="1" />
The ids of the blobs to parse.</t>

<t>properties: <spanx style="verb">String[]</spanx><vspace blankLines="1" />
If supplied, only the properties listed in the array are returned for each Email object. If omitted, defaults to:
<vspace blankLines="1" />
[ &quot;messageId&quot;, &quot;inReplyTo&quot;, &quot;references&quot;, &quot;sender&quot;, &quot;from&quot;, &quot;to&quot;, &quot;cc&quot;, &quot;bcc&quot;, &quot;replyTo&quot;, &quot;subject&quot;, &quot;sentAt&quot;, &quot;hasAttachment&quot;, &quot;preview&quot;, &quot;bodyValues&quot;, &quot;textBody&quot;, &quot;htmlBody&quot;, &quot;attachments&quot; ]</t>

<t>bodyProperties: <spanx style="verb">String[]</spanx><vspace blankLines="1" />
A list of properties to fetch for each EmailBodyPart returned. If omitted, defaults to the same value as the <spanx style="verb">Email/get</spanx> <spanx style="verb">bodyProperties</spanx> default argument.</t>
<t>fetchTextBodyValues: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
If true, the <spanx style="verb">bodyValues</spanx> property includes any <spanx style="verb">text/*</spanx> part in the <spanx style="verb">textBody</spanx> property.</t>

<t>fetchHTMLBodyValues: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
If true, the <spanx style="verb">bodyValues</spanx> property includes any <spanx style="verb">text/*</spanx> part in the <spanx style="verb">htmlBody</spanx> property.</t>

<t>fetchAllBodyValues: <spanx style="verb">Boolean</spanx> (default: false)<vspace blankLines="1" />
If true, the <spanx style="verb">bodyValues</spanx> property includes any <spanx style="verb">text/*</spanx> part in the <spanx style="verb">bodyStructure</spanx> property.</t>

<t>maxBodyValueBytes: <spanx style="verb">UnsignedInt</spanx> (default: 0)<vspace blankLines="1" />
If greater than zero, the <spanx style="verb">value</spanx> property of any EmailBodyValue object returned in <spanx style="verb">bodyValues</spanx> MUST be truncated if necessary so it does not exceed this number of octets in size. If 0 (the default), no truncation occurs.
<vspace blankLines="1" />
The server MUST ensure the truncation results in valid UTF-8 and does not occur mid-codepoint. If the part is of type <spanx style="verb">text/html</spanx>, the server SHOULD NOT truncate inside an HTML tag, e.g., in the middle of <spanx style="verb">&lt;a href="https://example.com"&gt;</spanx>. There is no requirement for the truncated form to be a balanced tree or valid HTML (indeed, the original source may well be neither of these things).</t>
</list>
</t>
<t>The response has the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx><vspace blankLines="1" />
The id of the account used for the call.</t>

<t>parsed: <spanx style="verb">Id[Email]|null</spanx><vspace blankLines="1" />
A map of blob id to parsed Email representation for each successfully parsed blob, or null if none.</t>

<t>notParsable: <spanx style="verb">Id[]|null</spanx><vspace blankLines="1" />
A list of ids given that corresponded to blobs that could not be parsed as Emails, or null if none.</t>

<t>notFound: <spanx style="verb">Id[]|null</spanx><vspace blankLines="1" />
A list of blob ids given that could not be found, or null if none.</t>
</list>
</t>
<t>As specified above, parsed forms of headers may only be used on appropriate header fields. Attempting to fetch a form that is forbidden (e.g., <spanx style="verb">header:From:asDate</spanx>) MUST result in the method call being rejected with an <spanx style="verb">invalidArguments</spanx> error.
</t>
<t>Where a specific header field is requested as a property, the capitalization of the property name in the response MUST be identical to that used in the request.
</t>
</section>

<section anchor="examples" title="Examples">
<t>A client logs in for the first time. It first fetches the set of Mailboxes. Now it will display the inbox to the user, which we will presume has Mailbox id &quot;fb666a55&quot;. The inbox may be (very!) large, but the user's screen is only so big, so the client can just load the Threads it needs to fill the screen and then load in more only when the user scrolls. The client sends this request:
</t>

<figure align="center"><artwork align="center">
[[ "Email/query",{
  "accountId": "ue150411c",
  "filter": {
    "inMailbox": "fb666a55"
  },
  "sort": [{
    "isAscending": false,
    "property": "receivedAt"
  }],
  "collapseThreads": true,
  "position": 0,
  "limit": 30,
  "calculateTotal": true
}, "0" ],
[ "Email/get", {
  "accountId": "ue150411c",
  "#ids": {
    "resultOf": "0",
    "name": "Email/query",
    "path": "/ids"
  },
  "properties": [
    "threadId"
  ]
}, "1" ],
[ "Thread/get", {
  "accountId": "ue150411c",
  "#ids": {
    "resultOf": "1",
    "name": "Email/get",
    "path": "/list/*/threadId"
  }
}, "2" ],
[ "Email/get", {
  "accountId": "ue150411c",
  "#ids": {
    "resultOf": "2",
    "name": "Thread/get",
    "path": "/list/*/emailIds"
  },
  "properties": [
    "threadId",
    "mailboxIds",
    "keywords",
    "hasAttachment",
    "from",
    "subject",
    "receivedAt",
    "size",
    "preview"
  ]
}, "3" ]]
</artwork></figure>
<t>Let's break down the 4 method calls to see what they're doing:
</t>
<t>&quot;0&quot;: This asks the server for the ids of the first 30 Email objects in the inbox, sorted newest first, ignoring Emails from the same Thread as a newer Email in the Mailbox (i.e., it is the first 30 unique Threads).
</t>
<t>&quot;1&quot;: Now we use a back-reference to fetch the Thread ids for each of these Email ids.
</t>
<t>&quot;2&quot;: Another back-reference fetches the Thread object for each of these Thread ids.
</t>
<t>&quot;3&quot;: Finally, we fetch the information we need to display the Mailbox listing (but no more!) for every Email in each of these 30 Threads. The client may aggregate this data for display, for example, by showing the Thread as &quot;flagged&quot; if any of the Emails in it has the <spanx style="verb">$flagged</spanx> keyword.
</t>
<t>The response from the server may look something like this:
</t>

<figure align="center"><artwork align="center">
[[ "Email/query", {
  "accountId": "ue150411c",
  "queryState": "09aa9a075588-780599:0",
  "canCalculateChanges": true,
  "position": 0,
  "total": 115,
  "ids": [ "Ma783e5cdf5f2deffbc97930a",
    "M9bd17497e2a99cb345fc1d0a", ... ]
}, "0" ],
[ "Email/get", {
  "accountId": "ue150411c",
  "state": "780599",
  "list": [{
    "id": "Ma783e5cdf5f2deffbc97930a",
    "threadId": "T36703c2cfe9bd5ed"
  }, {
    "id": "M9bd17497e2a99cb345fc1d0a",
    "threadId": "T0a22ad76e9c097a1"
  }, ... ],
  "notFound": []
}, "1" ],
[ "Thread/get", {
  "accountId": "ue150411c",
  "state": "22a8728b",
  "list": [{
    "id": "T36703c2cfe9bd5ed",
    "emailIds": [ "Ma783e5cdf5f2deffbc97930a" ]
  }, {
    "id": "T0a22ad76e9c097a1",
    "emailIds": [ "M3b568670a63e5d100f518fa5",
      "M9bd17497e2a99cb345fc1d0a" ]
  },  ... ],
  "notFound": []
}, "2" ],
[ "Email/get", {
  "accountId": "ue150411c",
  "state": "780599",
  "list": [{
    "id": "Ma783e5cdf5f2deffbc97930a",
    "threadId": "T36703c2cfe9bd5ed",
    "mailboxIds": {
      "fb666a55": true
    },
    "keywords": {
      "$seen": true,
      "$flagged": true
    },
    "hasAttachment": true,
    "from": [{
      "email": "jdoe@example.com",
      "name": "Jane Doe"
    }],
    "subject": "The Big Reveal",
    "receivedAt": "2018-06-27T00:20:35Z",
    "size": 175047,
    "preview": "As you may be aware, we are required to prepare a
      presentation where we wow a panel of 5 random members of the
      public, on or before 30 June each year.  We have drafted..."
  },
  ...
  ],
  "notFound": []
}, "3" ]]
</artwork></figure>
<t>Now, on another device, the user marks the first Email as unread, sending this API request:
</t>

<figure align="center"><artwork align="center">
[[ "Email/set", {
  "accountId": "ue150411c",
  "update": {
    "Ma783e5cdf5f2deffbc97930a": {
      "keywords/$seen": null
    }
  }
}, "0" ]]
</artwork></figure>
<t>The server applies this and sends the success response:
</t>

<figure align="center"><artwork align="center">
[[ "Email/set", {
  "accountId": "ue150411c",
  "oldState": "780605",
  "newState": "780606",
  "updated": {
    "Ma783e5cdf5f2deffbc97930a": null
  },
  ...
}, "0" ]]
</artwork></figure>
<t>The user also deletes a few Emails, and then a new message arrives.
</t>
<t>Back on our original machine, we receive a push update that the state string for Email is now &quot;780800&quot;. As this does not match the client's current state, it issues a request for the changes:
</t>

<figure align="center"><artwork align="center">
[[ "Email/changes", {
  "accountId": "ue150411c",
  "sinceState": "780605",
  "maxChanges": 50
}, "3" ],
[ "Email/queryChanges", {
  "accountId": "ue150411c",
  "filter": {
    "inMailbox": "fb666a55"
  },
  "sort": [{
    "property": "receivedAt",
    "isAscending": false
  }],
  "collapseThreads": true,
  "sinceQueryState": "09aa9a075588-780599:0",
  "upToId": "Mc2781d5e856a908d8a35a564",
  "maxChanges": 25,
  "calculateTotal": true
}, "11" ]]
</artwork></figure>
<t>The response:
</t>

<figure align="center"><artwork align="center">
[[ "Email/changes", {
  "accountId": "ue150411c",
  "oldState": "780605",
  "newState": "780800",
  "hasMoreChanges": false,
  "created": [ "Me8de6c9f6de198239b982ea2" ],
  "updated": [ "Ma783e5cdf5f2deffbc97930a" ],
  "destroyed": [ "M9bd17497e2a99cb345fc1d0a", ... ]
}, "3" ],
[ "Email/queryChanges", {
  "accountId": "ue150411c",
  "oldQueryState": "09aa9a075588-780599:0",
  "newQueryState": "e35e9facf117-780615:0",
  "added": [{
    "id": "Me8de6c9f6de198239b982ea2",
    "index": 0
  }],
  "removed": [ "M9bd17497e2a99cb345fc1d0a" ],
  "total": 115
}, "11" ]]
</artwork></figure>
<t>The client can update its local cache of the query results by removing &quot;M9bd17497e2a99cb345fc1d0a&quot; and then splicing in &quot;Me8de6c9f6de198239b982ea2&quot; at position 0. As it does not have the data for this new Email, it will then fetch it (it also could have done this in the same request using back-references).
</t>
<t>It knows something has changed about &quot;Ma783e5cdf5f2deffbc97930a&quot;, so it will refetch the Mailbox ids and keywords (the only mutable properties) for this Email too.
</t>
<t>The user starts composing a new Email. The email is plaintext and the client knows the email in English so adds this metadata to the body part. The user saves a draft while the composition is still in progress. The client sends:
</t>

<figure align="center"><artwork align="center">
[[ "Email/set", {
  "accountId": "ue150411c",
  "create": {
    "k192": {
      "mailboxIds": {
        "2ea1ca41b38e": true
      },
      "keywords": {
        "$seen": true,
        "$draft": true
      },
      "from": [{
        "name": "Joe Bloggs",
        "email": "joe@example.com"
      }],
      "subject": "World domination",
      "receivedAt": "2018-07-10T01:03:11Z",
      "sentAt": "2018-07-10T11:03:11+10:00",
      "bodyStructure": {
        "type": "text/plain",
        "partId": "bd48",
        "header:Content-Language": "en"
      },
      "bodyValues": {
        "bd48": {
          "value": "I have the most brilliant plan.  Let me tell
            you all about it.  What we do is, we",
          "isTruncated": false
        }
      }
    }
  }
}, "0" ]]
</artwork></figure>
<t>The server creates the message and sends the success response:
</t>

<figure align="center"><artwork align="center">
[[ "Email/set", {
  "accountId": "ue150411c",
  "oldState": "780823",
  "newState": "780839",
  "created": {
    "k192": {
      "id": "Mf40b5f831efa7233b9eb1c7f",
      "blobId": "Gf40b5f831efa7233b9eb1c7f8f97d84eeeee64f7",
      "threadId": "Td957e72e89f516dc",
      "size": 359
    }
  },
  ...
}, "0" ]]
</artwork></figure>
<t>The message created on the server looks something like this:
</t>

<figure align="center"><artwork align="center">
Message-Id: &lt;bbce0ae9-58be-4b24-ac82-deb840d58016@sloti7d1t02&gt;
User-Agent: Cyrus-JMAP/3.1.6-736-gdfb8e44
Mime-Version: 1.0
Date: Tue, 10 Jul 2018 11:03:11 +1000
From: "Joe Bloggs" &lt;joe@example.com&gt;
Subject: World domination
Content-Language: en
Content-Type: text/plain

I have the most brilliant plan.  Let me tell you all about it.  What we
do is, we
</artwork></figure>
<t>The user adds a recipient and converts the message to HTML so they can add formatting, then saves an updated draft:
</t>

<figure align="center"><artwork align="center">
[[ "Email/set", {
  "accountId": "ue150411c",
  "create": {
    "k1546": {
      "mailboxIds": {
        "2ea1ca41b38e": true
      },
      "keywords": {
        "$seen": true,
        "$draft": true
      },
      "from": [{
        "name": "Joe Bloggs",
        "email": "joe@example.com"
      }],
      "to": [{
        "name": "John",
        "email": "john@example.com"
      }],
      "subject": "World domination",
      "receivedAt": "2018-07-10T01:05:08Z",
      "sentAt": "2018-07-10T11:05:08+10:00",
      "bodyStructure": {
        "type": "multipart/alternative",
        "subParts": [{
          "partId": "a49d",
          "type": "text/html",
          "header:Content-Language": "en"
        }, {
          "partId": "bd48",
          "type": "text/plain",
          "header:Content-Language": "en"
        }]
      },
      "bodyValues": {
        "bd48": {
          "value": "I have the most brilliant plan.  Let me tell
            you all about it.  What we do is, we",
          "isTruncated": false
        },
        "a49d": {
          "value": "&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;
            &lt;style type=\"text/css\"&gt;div{font-size:16px}&lt;/style&gt;&lt;/head&gt;
            &lt;body&gt;&lt;div&gt;I have the most &lt;b&gt;brilliant&lt;/b&gt; plan.  Let me
            tell you all about it.  What we do is, we&lt;/div&gt;&lt;/body&gt;
            &lt;/html&gt;",
          "isTruncated": false
        }
      }
    }
  },
  "destroy": [ "Mf40b5f831efa7233b9eb1c7f" ]
}, "0" ]]
</artwork></figure>
<t>The server creates the new draft, deletes the old one, and sends the success response:
</t>

<figure align="center"><artwork align="center">
[[ "Email/set", {
  "accountId": "ue150411c",
  "oldState": "780839",
  "newState": "780842",
  "created": {
    "k1546": {
      "id": "Md45b47b4877521042cec0938",
      "blobId": "Ge8de6c9f6de198239b982ea214e0f3a704e4af74",
      "threadId": "Td957e72e89f516dc",
      "size": 11721
    }
  },
  "destroyed": [ "Mf40b5f831efa7233b9eb1c7f" ],
  ...
}, "0" ]]
</artwork></figure>
<t>The client moves this draft to a different account. The only way to do this is via the <spanx style="verb">Email/copy</spanx> method. It MUST set a new <spanx style="verb">mailboxIds</spanx> property, since the current value will not be valid Mailbox ids in the destination account:
</t>

<figure align="center"><artwork align="center">
[[ "Email/copy", {
  "fromAccountId": "ue150411c",
  "accountId": "u6c6c41ac",
  "create": {
    "k45": {
      "id": "Md45b47b4877521042cec0938",
      "mailboxIds": {
        "75a4c956": true
      }
    }
  },
  "onSuccessDestroyOriginal": true
}, "0" ]]
</artwork></figure>
<t>The server successfully copies the Email and deletes the original. Due to the implicit call to &quot;Email/set&quot;, there are two responses to the single method call, both with the same method call id:
</t>

<figure align="center"><artwork align="center">
[[ "Email/copy", {
  "fromAccountId": "ue150411c",
  "accountId": "u6c6c41ac",
  "oldState": "7ee7e9263a6d",
  "newState": "5a0d2447ed26",
  "created": {
    "k45": {
      "id": "M138f9954a5cd2423daeafa55",
      "blobId": "G6b9fb047cba722c48c611e79233d057c6b0b74e8",
      "threadId": "T2f242ea424a4079a",
      "size": 11721
    }
  },
  "notCreated": null
}, "0" ],
[ "Email/set", {
  "accountId": "ue150411c",
  "oldState": "780842",
  "newState": "780871",
  "destroyed": [ "Md45b47b4877521042cec0938" ],
  ...
}, "0" ]]
</artwork></figure>
</section>
</section>

<section anchor="search-snippets" title="Search Snippets">
<t>When doing a search on a <spanx style="verb">String</spanx> property, the client may wish to show the relevant section of the body that matches the search as a preview and to highlight any matching terms in both this and the subject of the Email. Search snippets represent this data.
</t>
<t>A <spanx style="strong">SearchSnippet</spanx> object has the following properties:
</t>
<t>
<list style="symbols">
<t>emailId: <spanx style="verb">Id</spanx><vspace blankLines="1" />
The Email id the snippet applies to.</t>

<t>subject: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
If text from the filter matches the subject, this is the subject of the Email with the following transformations:
<list style="numbers">
<t>Any instance of the following three characters MUST be replaced by an appropriate HTML entity: &amp; (ampersand), &lt; (less-than sign), and &gt; (greater-than sign) <xref target="HTML"/>. Other characters MAY also be replaced with an HTML entity form.</t>

<t>The matching words/phrases from the filter are wrapped in HTML <spanx style="verb">&lt;mark&gt;&lt;/mark&gt;</spanx> tags.</t>
</list>
If the subject does not match text from the filter, this property is null.</t>

<t>preview: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
If text from the filter matches the plaintext or HTML body, this is the relevant section of the body (converted to plaintext if originally HTML), with the same transformations as the <spanx style="verb">subject</spanx> property. It MUST NOT be bigger than 255 octets in size. If the body does not contain a match for the text from the filter, this property is null.</t>
</list>
</t>
<t>What is a relevant section of the body for preview is server defined. If the server is unable to determine search snippets, it MUST return null for both the <spanx style="verb">subject</spanx> and <spanx style="verb">preview</spanx> properties.
</t>
<t>Note that unlike most data types, a SearchSnippet DOES NOT have a property called <spanx style="verb">id</spanx>.
</t>
<t>The following JMAP method is supported.
</t>

<section anchor="searchsnippetget" title="SearchSnippet/get">
<t>To fetch search snippets, make a call to <spanx style="verb">SearchSnippet/get</spanx>. It takes the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx><vspace blankLines="1" />
The id of the account to use.</t>

<t>filter: <spanx style="verb">FilterOperator|FilterCondition|null</spanx><vspace blankLines="1" />
The same filter as passed to <spanx style="verb">Email/query</spanx>; see the description of this method in <xref target="emailquery"/> for details.</t>

<t>emailIds: <spanx style="verb">Id[]</spanx><vspace blankLines="1" />
The ids of the Emails to fetch snippets for.</t>
</list>
</t>
<t>The response has the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx><vspace blankLines="1" />
The id of the account used for the call.</t>

<t>list: <spanx style="verb">SearchSnippet[]</spanx><vspace blankLines="1" />
An array of SearchSnippet objects for the requested Email ids. This may not be in the same order as the ids that were in the request.</t>

<t>notFound: <spanx style="verb">Id[]|null</spanx><vspace blankLines="1" />
An array of Email ids requested that could not be found, or null if all
ids were found.</t>
</list>
</t>
<t>As the search snippets are derived from the message content and the algorithm for doing so could change over time, fetching the same snippets a second time MAY return a different result. However, the previous value is not considered incorrect, so there is no state string or update mechanism needed.
</t>
<t>The following additional errors may be returned instead of the <spanx style="verb">SearchSnippet/get</spanx> response:
</t>
<t><spanx style="verb">requestTooLarge</spanx>: The number of <spanx style="verb">emailIds</spanx> requested by the client exceeds the maximum number the server is willing to process in a single method call.
</t>
<t><spanx style="verb">unsupportedFilter</spanx>: The server is unable to process the given <spanx style="verb">filter</spanx> for any reason.
</t>
</section>

<section anchor="example-4" title="Example">
<t>Here, we did an <spanx style="verb">Email/query</spanx> to search for any Email in the account containing the word &quot;foo&quot;; now, we are fetching the search snippets for some of the ids that were returned in the results:
</t>

<figure align="center"><artwork align="center">
[[ "SearchSnippet/get", {
  "accountId": "ue150411c",
  "filter": {
    "text": "foo"
  },
  "emailIds": [
    "M44200ec123de277c0c1ce69c",
    "M7bcbcb0b58d7729686e83d99",
    "M28d12783a0969584b6deaac0",
    ...
  ]
}, "0" ]]
</artwork></figure>
<t>Example response:
</t>

<figure align="center"><artwork align="center">
[[ "SearchSnippet/get", {
  "accountId": "ue150411c",
  "list": [{
      "emailId": "M44200ec123de277c0c1ce69c",
      "subject": null,
      "preview": null
  }, {
      "emailId": "M7bcbcb0b58d7729686e83d99",
      "subject": "The &lt;mark&gt;Foo&lt;/mark&gt;sball competition",
      "preview": "...year the &lt;mark&gt;foo&lt;/mark&gt;sball competition will
        be held in the Stadium de ..."
  }, {
      "emailId": "M28d12783a0969584b6deaac0",
      "subject": null,
      "preview": "...the &lt;mark&gt;Foo&lt;/mark&gt;/bar method results often
        returns &amp;lt;1 widget rather than the complete..."
  },
  ...
  ],
  "notFound": null
}, "0" ]]
</artwork></figure>
</section>
</section>

<section anchor="identities" title="Identities">
<t>An <spanx style="strong">Identity</spanx> object stores information about an email address or domain the user may send from. It has the following properties:
</t>
<t>
<list style="symbols">
<t>id: <spanx style="verb">Id</spanx> (immutable; server-set)<vspace blankLines="1" />
The id of the Identity.</t>

<t>name: <spanx style="verb">String</spanx> (default: &quot;&quot;)<vspace blankLines="1" />
The &quot;From&quot; name the client SHOULD use when creating a new Email from this Identity.</t>

<t>email: <spanx style="verb">String</spanx> (immutable)<vspace blankLines="1" />
The &quot;From&quot; email address the client MUST use when creating a new Email from this Identity. If the <spanx style="verb">mailbox</spanx> part of the address (the section before the &quot;@&quot;) is the single character <spanx style="verb">*</spanx> (e.g., <spanx style="verb">*@example.com</spanx>), the client may use any valid address ending in that domain (e.g., <spanx style="verb">foo@example.com</spanx>).</t>

<t>replyTo: <spanx style="verb">EmailAddress[]|null</spanx> (default: null)<vspace blankLines="1" />
The Reply-To value the client SHOULD set when creating a new Email from this Identity.</t>

<t>bcc: <spanx style="verb">EmailAddress[]|null</spanx> (default: null)<vspace blankLines="1" />
The Bcc value the client SHOULD set when creating a new Email from this Identity.</t>

<t>textSignature: <spanx style="verb">String</spanx> (default: &quot;&quot;)<vspace blankLines="1" />
A signature the client SHOULD insert into new plaintext messages that will be sent from this Identity. Clients MAY ignore this and/or combine this with a client-specific signature preference.</t>

<t>htmlSignature: <spanx style="verb">String</spanx> (default: &quot;&quot;)<vspace blankLines="1" />
A signature the client SHOULD insert into new HTML messages that will be sent from this Identity. This text MUST be an HTML snippet to be inserted into the <spanx style="verb">&lt;body&gt;&lt;/body&gt;</spanx> section of the HTML. Clients MAY ignore this and/or combine this with a client-specific signature preference.</t>

<t>mayDelete: <spanx style="verb">Boolean</spanx> (server-set)<vspace blankLines="1" />
Is the user allowed to delete this Identity? Servers may wish to set this to false for the user's username or other default address. Attempts to destroy an Identity with <spanx style="verb">mayDelete: false</spanx> will be rejected with a standard <spanx style="verb">forbidden</spanx> SetError.</t>
</list>
</t>
<t>See the &quot;Addresses&quot; header form description in the Email object (<xref target="addresses"/>) for the definition of EmailAddress.
</t>
<t>Multiple identities with the same email address MAY exist, to allow for different settings the user wants to pick between (for example, with different names/signatures).
</t>
<t>The following JMAP methods are supported.
</t>

<section anchor="identityget" title="Identity/get">
<t>This is a standard &quot;/get&quot; method as described in <xref target="RFC8620"/>, Section 5.1. The <spanx style="verb">ids</spanx> argument may be null to fetch all at once.
</t>
</section>

<section anchor="identitychanges" title="Identity/changes">
<t>This is a standard &quot;/changes&quot; method as described in <xref target="RFC8620"/>, Section 5.2.
</t>
</section>

<section anchor="identityset" title="Identity/set">
<t>This is a standard &quot;/set&quot; method as described in <xref target="RFC8620"/>, Section 5.3. The following extra SetError types are defined:
</t>
<t>For <spanx style="verb">create</spanx>:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">forbiddenFrom</spanx>: The user is not allowed to send from the address given as
the <spanx style="verb">email</spanx> property of the Identity.</t>
</list>
</t>
</section>

<section anchor="example-5" title="Example">
<t>Request:
</t>

<figure align="center"><artwork align="center">
[ "Identity/get", {
  "accountId": "acme"
}, "0" ]
</artwork></figure>
<t>with response:
</t>

<figure align="center"><artwork align="center">
[ "Identity/get", {
  "accountId": "acme",
  "state": "99401312ae-11-333",
  "list": [
    {
      "id": "XD-3301-222-11_22AAz",
      "name": "Joe Bloggs",
      "email": "joe@example.com",
      "replyTo": null,
      "bcc": [{
        "name": null,
        "email": "joe+archive@example.com"
      }],
      "textSignature": "-- \nJoe Bloggs\nMaster of Email",
      "htmlSignature": "&lt;div&gt;&lt;b&gt;Joe Bloggs&lt;/b&gt;&lt;/div&gt;
        &lt;div&gt;Master of Email&lt;/div&gt;",
      "mayDelete": false
    },
    {
      "id": "XD-9911312-11_22AAz",
      "name": "Joe B",
      "email": "*@example.com",
      "replyTo": null,
      "bcc": null,
      "textSignature": "",
      "htmlSignature": "",
      "mayDelete": true
    }
  ],
  "notFound": []
}, "0" ]
</artwork></figure>
</section>
</section>

<section anchor="email-submission" title="Email Submission">
<t>An <spanx style="strong">EmailSubmission</spanx> object represents the submission of an Email for delivery to one or more recipients. It has the following properties:
</t>
<t>
<list style="symbols">
<t>id: <spanx style="verb">Id</spanx> (immutable; server-set)<vspace blankLines="1" />
The id of the EmailSubmission.</t>

<t>identityId: <spanx style="verb">Id</spanx> (immutable)<vspace blankLines="1" />
The id of the Identity to associate with this submission.</t>

<t>emailId: <spanx style="verb">Id</spanx> (immutable)<vspace blankLines="1" />
The id of the Email to send. The Email being sent does not have to be a draft, for example, when &quot;redirecting&quot; an existing Email to a different address.</t>

<t>threadId: <spanx style="verb">Id</spanx> (immutable; server-set)<vspace blankLines="1" />
The Thread id of the Email to send. This is set by the server to the <spanx style="verb">threadId</spanx> property of the Email referenced by the <spanx style="verb">emailId</spanx>.</t>

<t>envelope: <spanx style="verb">Envelope|null</spanx> (immutable)<vspace blankLines="1" />
Information for use when sending via SMTP.
An <spanx style="strong">Envelope</spanx> object has the following properties:
<list style="symbols">
<t>mailFrom: <spanx style="verb">Address</spanx><vspace blankLines="1" />
The email address to use as the return address in the SMTP submission, plus any parameters to pass with the MAIL FROM address. The JMAP server MAY allow the address to be the empty string.
<vspace blankLines="1" />
When a JMAP server performs an SMTP message submission, it MAY use the
same id string for the ENVID parameter <xref target="RFC3461"/> and the
EmailSubmission object id. Servers that do this MAY replace a
client-provided value for ENVID with a server-provided value.</t>

<t>rcptTo: <spanx style="verb">Address[]</spanx><vspace blankLines="1" />
The email addresses to send the message to, and any RCPT TO parameters to pass with the recipient.</t>
</list>
An <spanx style="strong">Address</spanx> object has the following properties:
<list style="symbols">
<t>email: <spanx style="verb">String</spanx><vspace blankLines="1" />
The email address being represented by the object. This is a &quot;Mailbox&quot; as used in the Reverse-path or Forward-path of the MAIL FROM or RCPT TO command in <xref target="RFC5321"/>.</t>

<t>parameters: <spanx style="verb">Object|null</spanx><vspace blankLines="1" />
Any parameters to send with the email address (either mail-parameter or rcpt-parameter as appropriate, as specified in <xref target="RFC5321"/>). If supplied, each key in the object is a parameter name, and the value is either the parameter value (type <spanx style="verb">String</spanx>) or null if the parameter does not take a value. For both name and value, any xtext or unitext encodings are removed (see <xref target="RFC3461"/> and <xref target="RFC6533"/>) and JSON string encoding is applied.</t>
</list>
If the <spanx style="verb">envelope</spanx> property is null or omitted on creation, the server MUST generate this from the referenced Email as follows:
<list style="symbols">
<t><spanx style="verb">mailFrom</spanx>: The email address in the Sender header field, if present; otherwise, it's the email address in the From header field, if present. In either case, no parameters are added.
<vspace blankLines="1" />
If multiple addresses are present in one of these header fields, or there is more than one Sender/From header field, the server SHOULD reject the EmailSubmission as invalid; otherwise, it MUST take the first address in the last Sender/From header field.
<vspace blankLines="1" />
If the address found from this is not allowed by the Identity associated with this submission, the <spanx style="verb">email</spanx> property from the Identity MUST be used instead.</t>

<t><spanx style="verb">rcptTo</spanx>: The deduplicated set of email addresses from the To, Cc, and Bcc header fields, if present, with no parameters for any of them.</t>
</list></t>
<t>sendAt: <spanx style="verb">UTCDate</spanx> (immutable; server-set)<vspace blankLines="1" />
The date the submission was/will be released for delivery.
If the client successfully used FUTURERELEASE <xref target="RFC4865"/> with the submission, this MUST be the time when the server will release the message; otherwise, it MUST be the time the EmailSubmission was created.</t>

<t>undoStatus: <spanx style="verb">String</spanx><vspace blankLines="1" />
This represents whether the submission may be canceled. This is server set on create and MUST be one of the following values:
<list style="symbols">
<t><spanx style="verb">pending</spanx>: It may be possible to cancel this submission.</t>
<t><spanx style="verb">final</spanx>: The message has been relayed to at least one recipient in a
manner that cannot be recalled. It is no longer possible to cancel this
submission.</t>

<t><spanx style="verb">canceled</spanx>: The submission was canceled and will not be delivered
to any recipient.</t>
</list>
On systems that do not support unsending, the value of this property will always be <spanx style="verb">final</spanx>. On systems that do support canceling submission, it will start as <spanx style="verb">pending</spanx> and MAY transition to <spanx style="verb">final</spanx> when the server knows it definitely cannot recall the message, but it MAY just remain <spanx style="verb">pending</spanx>. If in pending state, a client can attempt to cancel the submission by setting this property to <spanx style="verb">canceled</spanx>; if the update succeeds, the submission was successfully canceled, and the message has not been delivered to any of the original recipients.</t>

<t>deliveryStatus: <spanx style="verb">String[DeliveryStatus]|null</spanx> (server-set)<vspace blankLines="1" />
This represents the delivery status for each of the submission's recipients, if known. This property MAY not be supported by all servers, in which case it will remain null. Servers that support it SHOULD update the EmailSubmission object each time the status of any of the recipients changes, even if some recipients are still being retried.
<vspace blankLines="1" />
This value is a map from the email address of each recipient to a DeliveryStatus object.
<vspace blankLines="1" />
A <spanx style="strong">DeliveryStatus</spanx> object has the following properties:
<list style="symbols">
<t>smtpReply: <spanx style="verb">String</spanx><vspace blankLines="1" />
The SMTP reply string returned for this recipient when the server last tried
to relay the message, or in a later Delivery Status Notification (DSN, as defined in <xref target="RFC3464"/>) response for the message. This SHOULD be the response to the RCPT TO stage, unless this was accepted and the message as a whole was rejected at the end of the DATA stage, in which case the DATA stage reply SHOULD be used instead.
<vspace blankLines="1" />
Multi-line SMTP responses should be concatenated to a single string as follows:
<list style="symbols">
<t>The hyphen following the SMTP code on all but the last line is
replaced with a space.</t>
<t>Any prefix in common with the first line is stripped from lines after
the first.</t>
<t>CRLF is replaced by a space.</t>
</list>
For example:

<figure align="center"><artwork align="center">
550-5.7.1 Our system has detected that this message is
550 5.7.1 likely spam.
</artwork></figure>
would become:

<figure align="center"><artwork align="center">
550 5.7.1 Our system has detected that this message is likely spam.
</artwork></figure>
For messages relayed via an alternative to SMTP, the server MAY generate a synthetic string representing the status instead. If it does this, the string MUST be of the following form:
<list style="symbols">
<t>A 3-digit SMTP reply code, as defined in <xref target="RFC5321"/>, Section 4.2.3.</t>
<t>Then a single space character.</t>
<t>Then an SMTP Enhanced Mail System Status Code as defined in
<xref target="RFC3463"/>, with a registry defined in <xref target="RFC5248"/>.</t>
<t>Then a single space character.</t>
<t>Then an implementation-specific information string with a human-readable explanation of the response.</t>
</list></t>
<t>delivered: <spanx style="verb">String</spanx><vspace blankLines="1" />
Represents whether the message has been successfully delivered to the recipient. This MUST be one of the following values:
<list style="symbols">
<t><spanx style="verb">queued</spanx>: The message is in a local mail queue and the status will change
once it exits the local mail queues. The <spanx style="verb">smtpReply</spanx> property may still change.</t>
<t><spanx style="verb">yes</spanx>: The message was successfully delivered to the mail store of the
recipient. The <spanx style="verb">smtpReply</spanx> property is final.</t>
<t><spanx style="verb">no</spanx>: Delivery to the recipient permanently failed. The <spanx style="verb">smtpReply</spanx>
property is final.</t>
<t><spanx style="verb">unknown</spanx>: The final delivery status is unknown, (e.g., it was relayed
to an external machine and no further information is available). The <spanx style="verb">smtpReply</spanx> property may still change if a DSN arrives.</t>
</list>
Note that successful relaying to an external SMTP server SHOULD NOT be taken as an indication that the message has successfully reached the final mail store. In this case though, the server may receive a DSN response, if requested.
<vspace blankLines="1" />
If a DSN is received for the recipient with Action equal to &quot;delivered&quot;, as per <xref target="RFC3464"/>, Section 2.3.3, then the <spanx style="verb">delivered</spanx> property SHOULD be set to <spanx style="verb">yes</spanx>; if the Action equals &quot;failed&quot;, the property SHOULD be set to <spanx style="verb">no</spanx>. Receipt of any other DSN SHOULD NOT affect this property.
<vspace blankLines="1" />
The server MAY also set this property based on other feedback channels.</t>

<t>displayed: <spanx style="verb">String</spanx><vspace blankLines="1" />
Represents whether the message has been displayed to the recipient. This MUST be one of the following values:
<list style="symbols">
<t><spanx style="verb">unknown</spanx>: The display status is unknown. This is the initial value.</t>
<t><spanx style="verb">yes</spanx>: The recipient's system claims the message content has been
displayed to the recipient. Note that there is no guarantee that the recipient has noticed, read, or understood the content.</t>
</list>
If a Message Disposition Notification (MDN) is received for this recipient with Disposition-Type (as per <xref target="RFC8098"/>, Section 3.2.6.2) equal to &quot;displayed&quot;, this property SHOULD be set to <spanx style="verb">yes</spanx>.
<vspace blankLines="1" />
The server MAY also set this property based on other feedback channels.</t>
</list></t>
<t>dsnBlobIds: <spanx style="verb">Id[]</spanx> (server-set)<vspace blankLines="1" />
A list of blob ids for DSNs <xref target="RFC3464"/> received for this submission, in order of receipt, oldest first. The blob is the whole MIME message (with a top-level content-type of <spanx style="verb">multipart/report</spanx>), as received.</t>

<t>mdnBlobIds: <spanx style="verb">Id[]</spanx> (server-set)<vspace blankLines="1" />
A list of blob ids for MDNs <xref target="RFC8098"/> received for this submission, in order of receipt, oldest first. The blob is the whole MIME message (with a top-level content-type of <spanx style="verb">multipart/report</spanx>), as received.</t>
</list>
</t>
<t>JMAP servers MAY choose not to expose DSN and MDN responses as Email objects if they correlate to an EmailSubmission object. It SHOULD only do this if it exposes them in the <spanx style="verb">dsnBlobIds</spanx> and <spanx style="verb">mdnblobIds</spanx> fields instead, and it expects the user to be using clients capable of fetching and displaying delivery status via the EmailSubmission object.
</t>
<t>For efficiency, a server MAY destroy EmailSubmission objects at any time after the message is successfully sent or after it has finished
retrying to send the message. For very basic SMTP proxies, this MAY be immediately after creation, as it has no way to assign a real id and return the information again if fetched later.
</t>
<t>The following JMAP methods are supported.
</t>

<section anchor="emailsubmissionget" title="EmailSubmission/get">
<t>This is a standard &quot;/get&quot; method as described in <xref target="RFC8620"/>, Section 5.1.
</t>
</section>

<section anchor="emailsubmissionchanges" title="EmailSubmission/changes">
<t>This is a standard &quot;/changes&quot; method as described in <xref target="RFC8620"/>, Section 5.2.
</t>
</section>

<section anchor="emailsubmissionquery" title="EmailSubmission/query">
<t>This is a standard &quot;/query&quot; method as described in <xref target="RFC8620"/>, Section 5.5.
</t>
<t>A <spanx style="strong">FilterCondition</spanx> object has the following properties, any of which may be omitted:
</t>
<t>
<list style="symbols">
<t>identityIds: <spanx style="verb">Id[]</spanx><vspace blankLines="1" />
The EmailSubmission <spanx style="verb">identityId</spanx> property must be in this list to match the
condition.</t>
<t>emailIds: <spanx style="verb">Id[]</spanx><vspace blankLines="1" />
The EmailSubmission <spanx style="verb">emailId</spanx> property must be in this list to match the
condition.</t>
<t>threadIds: <spanx style="verb">Id[]</spanx><vspace blankLines="1" />
The EmailSubmission <spanx style="verb">threadId</spanx> property must be in this list to match the
condition.</t>
<t>undoStatus: <spanx style="verb">String</spanx><vspace blankLines="1" />
The EmailSubmission <spanx style="verb">undoStatus</spanx> property must be identical to the value given to match the condition.</t>
<t>before: <spanx style="verb">UTCDate</spanx><vspace blankLines="1" />
The <spanx style="verb">sendAt</spanx> property of the EmailSubmission object must be before this date-time to match the condition.</t>
<t>after: <spanx style="verb">UTCDate</spanx><vspace blankLines="1" />
The <spanx style="verb">sendAt</spanx> property of the EmailSubmission object must be the same as or after this date-time to match the condition.</t>
</list>
</t>
<t>An EmailSubmission object matches the FilterCondition if and only if all of the given conditions match. If zero properties are specified, it is automatically true for all objects.
</t>
<t>The following EmailSubmission properties MUST be supported for sorting:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">emailId</spanx></t>
<t><spanx style="verb">threadId</spanx></t>
<t><spanx style="verb">sentAt</spanx></t>
</list>
</t>
</section>

<section anchor="emailsubmissionquerychanges" title="EmailSubmission/queryChanges">
<t>This is a standard &quot;/queryChanges&quot; method as described in <xref target="RFC8620"/>, Section 5.6.
</t>
</section>

<section anchor="emailsubmissionset" title="EmailSubmission/set">
<t>This is a standard &quot;/set&quot; method as described in <xref target="RFC8620"/>, Section 5.3 with the following two additional request arguments:
</t>
<t>
<list style="symbols">
<t>onSuccessUpdateEmail: <spanx style="verb">Id[PatchObject]|null</spanx><vspace blankLines="1" />
A map of EmailSubmission id to an object containing properties to update on the Email object referenced by the EmailSubmission if the create/update/destroy succeeds. (For references to EmailSubmissions created in the same &quot;/set&quot; invocation, this is equivalent to a creation-reference, so the id will be the creation id prefixed with a <spanx style="verb">#</spanx>.)</t>

<t>onSuccessDestroyEmail: <spanx style="verb">Id[]|null</spanx><vspace blankLines="1" />
A list of EmailSubmission ids for which the Email with the corresponding <spanx style="verb">emailId</spanx> should be destroyed if the create/update/destroy succeeds. (For references to EmailSubmission creations, this is equivalent to a creation-reference, so the id will be the creation id prefixed with a <spanx style="verb">#</spanx>.)</t>
</list>
</t>
<t>After all create/update/destroy items in the <spanx style="verb">EmailSubmission/set</spanx> invocation  have been processed, a single implicit <spanx style="verb">Email/set</spanx> call MUST be made to perform any changes requested in these two arguments. The response to this MUST be returned after the <spanx style="verb">EmailSubmission/set</spanx> response.
</t>
<t>An Email is sent by creating an EmailSubmission object. When processing each create, the server must check that the message is valid, and the user has sufficient authorisation to send it. If the creation succeeds, the message will be sent to the recipients given in the envelope <spanx style="verb">rcptTo</spanx> parameter. The server MUST remove any Bcc header field present on the message during delivery. The server MAY add or remove other header fields from the submitted message or make further alterations in accordance with the server's policy during delivery.
</t>
<t>If the referenced Email is destroyed at any point after the EmailSubmission object is created, this MUST NOT change the behaviour of the submission (i.e., it does not cancel a future send). The <spanx style="verb">emailId</spanx> and <spanx style="verb">threadId</spanx> properties of the EmailSubmission object remain, but trying to fetch them (with a standard <spanx style="verb">Email/get</spanx> call) will return a <spanx style="verb">notFound</spanx> error if the corresponding objects have been destroyed.
</t>
<t>Similarly, destroying an EmailSubmission object MUST NOT affect the deliveries it represents. It purely removes the record of the submission. The server MAY automatically destroy EmailSubmission objects after some time or in response to other triggers, and MAY forbid the client from manually destroying EmailSubmission objects.
</t>
<t>If the message to be sent is larger than the server supports sending, a standard <spanx style="verb">tooLarge</spanx> SetError MUST be returned. A <spanx style="verb">maxSize</spanx> <spanx style="verb">UnsignedInt</spanx> property MUST be present on the SetError specifying the maximum size of an message that may be sent, in octets.
</t>
<t>If the Email or Identity id given cannot be found, the submission creation is rejected with a standard <spanx style="verb">invalidProperties</spanx> SetError.
</t>
<t>The following extra SetError types are defined:
</t>
<t>For <spanx style="verb">create</spanx>:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">invalidEmail</spanx> - The Email to be sent is invalid in some way. The
SetError SHOULD contain a property called <spanx style="verb">properties</spanx> of type <spanx style="verb">String[]</spanx> that lists <spanx style="strong">all</spanx> the properties of the Email that were invalid.</t>

<t><spanx style="verb">tooManyRecipients</spanx> - The envelope (supplied or generated) has more
recipients than the server allows. A <spanx style="verb">maxRecipients</spanx> <spanx style="verb">UnsignedInt</spanx> property MUST also be present on the SetError specifying the maximum number of allowed recipients.</t>

<t><spanx style="verb">noRecipients</spanx> - The envelope (supplied or generated) does not have any
rcptTo email addresses.</t>

<t><spanx style="verb">invalidRecipients</spanx> - The <spanx style="verb">rcptTo</spanx> property of the envelope (supplied or
generated) contains at least one rcptTo value, which is not a valid email address
for sending to. An <spanx style="verb">invalidRecipients</spanx> <spanx style="verb">String[]</spanx> property MUST also be present on the SetError, which is a list of the invalid addresses.</t>
<t><spanx style="verb">forbiddenMailFrom</spanx> - The server does not permit the user to send a message
with the envelope From address <xref target="RFC5321"/>.</t>

<t><spanx style="verb">forbiddenFrom</spanx> - The server does not permit the user to send a message
with the From header field <xref target="RFC5322"/> of the message to be sent.</t>

<t><spanx style="verb">forbiddenToSend</spanx> - The user does not have permission to send at all right
now for some reason. A <spanx style="verb">description</spanx> <spanx style="verb">String</spanx> property MAY be present on the SetError object to display to the user why they are not permitted.</t>
</list>
</t>
<t>For <spanx style="verb">update</spanx>:
</t>
<t>
<list style="symbols">
<t><spanx style="verb">cannotUnsend</spanx> - The client attempted to update the <spanx style="verb">undoStatus</spanx> of a valid
EmailSubmission object from <spanx style="verb">pending</spanx> to <spanx style="verb">canceled</spanx>, but the message cannot be unsent.</t>
</list>
</t>

<section anchor="example-6" title="Example">
<t>The following example presumes a draft of the Email to be sent has already been saved, and its Email id is &quot;M7f6ed5bcfd7e2604d1753f6c&quot;. This call then sends the Email immediately, and if successful, removes the <spanx style="verb">$draft</spanx> flag and moves it from the drafts folder (which has Mailbox id &quot;7cb4e8ee-df87-4757-b9c4-2ea1ca41b38e&quot;) to the sent folder (which we presume has Mailbox id &quot;73dbcb4b-bffc-48bd-8c2a-a2e91ca672f6&quot;).
</t>

<figure align="center"><artwork align="center">
[[ "EmailSubmission/set", {
  "accountId": "ue411d190",
  "create": {
    "k1490": {
      "identityId": "I64588216",
      "emailId": "M7f6ed5bcfd7e2604d1753f6c",
      "envelope": {
        "mailFrom": {
          "email": "john@example.com",
          "parameters": null
        },
        "rcptTo": [{
          "email": "jane@example.com",
          "parameters": null
        },
        ...
        ]
      }
    }
  },
  "onSuccessUpdateEmail": {
    "#k1490": {
      "mailboxIds/7cb4e8ee-df87-4757-b9c4-2ea1ca41b38e": null,
      "mailboxIds/73dbcb4b-bffc-48bd-8c2a-a2e91ca672f6": true,
      "keywords/$draft": null
    }
  }
}, "0" ]]
</artwork></figure>
<t>A successful response might look like this. Note that there are two responses due to the implicit <spanx style="verb">Email/set</spanx> call, but both have the same method call id as they are due to the same call in the request:
</t>

<figure align="center"><artwork align="center">
[[ "EmailSubmission/set", {
  "accountId": "ue411d190",
  "oldState": "012421s6-8nrq-4ps4-n0p4-9330r951ns21",
  "newState": "355421f6-8aed-4cf4-a0c4-7377e951af36",
  "created": {
    "k1490": {
      "id": "ES-3bab7f9a-623e-4acf-99a5-2e67facb02a0"
    }
  }
}, "0" ],
[ "Email/set", {
  "accountId": "ue411d190",
  "oldState": "778193",
  "newState": "778197",
  "updated": {
      "M7f6ed5bcfd7e2604d1753f6c": null
  }
}, "0" ]]
</artwork></figure>
<t>Suppose instead an admin has removed sending rights for the user, so the submission is rejected with a &quot;forbiddenToSend&quot; error. The description argument of the error is intended for display to the user, so it should be localised appropriately. Let's suppose the request was sent with an Accept-Language header like this:
</t>

<figure align="center"><artwork align="center">
Accept-Language: de;q=0.9,en;q=0.8
</artwork></figure>
<t>The server should attempt to choose the best localisation from those it has available based on the Accept-Language header, as described in <xref target="RFC8620"/>, Section 3.8. If the server has English, French, and German translations, it would choose German as the preferred language and return a response like this:
</t>

<figure align="center"><artwork align="center">
[[ "EmailSubmission/set", {
  "accountId": "ue411d190",
  "oldState": "012421s6-8nrq-4ps4-n0p4-9330r951ns21",
  "newState": "012421s6-8nrq-4ps4-n0p4-9330r951ns21",
  "notCreated": {
    "k1490": {
      "type": "forbiddenToSend",
      "description": "Verzeihung, wegen verdaechtiger Aktivitaeten Ihres
       Benutzerkontos haben wir den Versand von Nachrichten gesperrt.
       Bitte wenden Sie sich fuer Hilfe an unser Support Team."
    }
  }
}, "0" ]]
</artwork></figure>
</section>
</section>
</section>

<section anchor="vacation-response" title="Vacation Response">
<t>A vacation response sends an automatic reply when a message is delivered to the mail store, informing the original sender that their message may not be read for some time.</t>
<t>Automated message sending can produce undesirable behaviour. To avoid this, implementors MUST follow the recommendations set forth in <xref target="RFC3834"/>.
</t>
<t>The <spanx style="strong">VacationResponse</spanx> object represents the state of vacation-response-related
settings for an account. It has the following properties:
</t>
<t>
<list style="symbols">
<t>id: <spanx style="verb">Id</spanx> (immutable; server-set)<vspace blankLines="1" />
The id of the object. There is only ever one VacationResponse object, and its id is <spanx style="verb">singleton</spanx>.</t>

<t>isEnabled: <spanx style="verb">Boolean</spanx><vspace blankLines="1" />
Should a vacation response be sent if a message arrives between the <spanx style="verb">fromDate</spanx> and <spanx style="verb">toDate</spanx>?</t>

<t>fromDate: <spanx style="verb">UTCDate|null</spanx><vspace blankLines="1" />
If <spanx style="verb">isEnabled</spanx> is true, messages that arrive on or after this date-time (but before the <spanx style="verb">toDate</spanx> if defined) should receive the user's vacation response. If null, the vacation response is effective immediately.</t>

<t>toDate: <spanx style="verb">UTCDate|null</spanx><vspace blankLines="1" />
If <spanx style="verb">isEnabled</spanx> is true, messages that arrive before this date-time (but on or after the <spanx style="verb">fromDate</spanx> if defined) should receive the user's vacation response. If null, the vacation response is effective indefinitely.</t>

<t>subject: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The subject that will be used by the message sent in response to messages when the vacation response is enabled. If null, an appropriate subject SHOULD be set by the server.</t>

<t>textBody: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The plaintext body to send in response to messages when the vacation response is enabled. If this is null, the server SHOULD generate a plaintext body part from the <spanx style="verb">htmlBody</spanx> when sending vacation responses but MAY choose to send the response as HTML only. If both <spanx style="verb">textBody</spanx> and <spanx style="verb">htmlBody</spanx> are null, an appropriate default body SHOULD be generated for responses by the server.</t>

<t>htmlBody: <spanx style="verb">String|null</spanx><vspace blankLines="1" />
The HTML body to send in response to messages when the vacation response is enabled. If this is null, the server MAY choose to generate an HTML body part from the <spanx style="verb">textBody</spanx> when sending vacation responses or MAY choose to send the response as plaintext only.</t>
</list>
</t>
<t>The following JMAP methods are supported.
</t>

<section anchor="vacationresponseget" title="VacationResponse/get">
<t>This is a standard &quot;/get&quot; method as described in <xref target="RFC8620"/>, Section 5.1.
</t>
<t>There MUST only be exactly one VacationResponse object in an account. It MUST have the id &quot;singleton&quot;.
</t>
</section>

<section anchor="vacationresponseset" title="VacationResponse/set">
<t>This is a standard &quot;/set&quot; method as described in <xref target="RFC8620"/>, Section 5.3.
</t>
</section>
</section>

<section anchor="security-considerations" title="Security Considerations">
<t>All security considerations of JMAP <xref target="RFC8620"/> apply to this specification. Additional considerations specific to the data types and functionality introduced by this document are described in the following subsections.
</t>

<section anchor="emailbodypart-value" title="EmailBodyPart Value">
<t>Service providers typically perform security filtering on incoming messages, and it's important that the detection of content-type and charset for the security filter aligns with the heuristics performed by JMAP servers. Servers that apply heuristics to determine the content-type or charset for an EmailBodyValue SHOULD document the heuristics and provide a mechanism to turn them off in the event they are misaligned with the security filter used at a particular mail host.
</t>
<t>Automatic conversion of charsets that allow hidden channels for ASCII text, such as UTF-7, have been problematic for security filters in the past, so server implementations can mitigate this risk by having such conversions  off-by-default and/or separately configurable.
</t>
<t>To allow the client to restrict the volume of data it can receive in response to a request, a maximum length may be requested for the data returned for a textual body part. However, truncating the data may change the semantic meaning, for example, truncating a URL changes its location. Servers that scan for links to malicious sites should take care to either ensure truncation is not at a semantically significant point or rescan the truncated value for malicious content before returning it.
</t>
</section>

<section anchor="html-email-display" title="HTML Email Display">
<t>HTML message bodies provide richer formatting for messages but present a number of security challenges, especially when embedded in a webmail context in combination with interface HTML. Clients that render HTML messages should carefully consider the potential risks, including:
</t>
<t>
<list style="symbols">
<t>Embedded JavaScript can rewrite the message to change its content on
subsequent opening, allowing users to be mislead. In webmail systems, if run in the same origin as the interface, it can access and exfiltrate all private data accessible to the user, including all other messages and potentially contacts, calendar events, settings, and credentials. It can also rewrite the interface to undetectably phish passwords. A compromise is likely to be persistent, not just for the duration of page load, due to exfiltration of session credentials or installation of a service worker that can intercept all subsequent network requests (however, this would only be possible if blob downloads are also available on the same origin, and the service worker script is attached to the message).</t>
<t>HTML documents may load content directly from the Internet rather than just
referencing attached resources. For example, you may have an <spanx style="verb">&lt;img&gt;</spanx> tag with an external <spanx style="verb">src</spanx> attribute. This may leak to the sender when a message is opened, as well as the IP address of the recipient. Cookies may also be sent and set by the server, allowing tracking between different messages and even website visits and advertising profiles.</t>
<t>In webmail systems, CSS can break the layout or create phishing
vulnerabilities. For example, the use of <spanx style="verb">position:fixed</spanx> can allow a message to draw content outside of its normal bounds, potentially clickjacking a real interface element.</t>
<t>If in a webmail context and not inside a separate frame, any styles defined in
CSS rules will apply to interface elements as well if the selector matches, allowing the interface to be modified. Similarly, any interface styles that match elements in the message will alter their appearance, potentially breaking the layout of the message.</t>
<t>The link text in HTML has no necessary correlation with the actual target of
the link, which can be used to make phishing attacks more convincing.</t>
<t>Links opened from a message or embedded external content may leak private info in the Referer header sent by default in most systems.</t>
<t>Forms can be used to mimic login boxes, providing a potent phishing vector if
allowed to submit directly from the message display.</t>
</list>
</t>
<t>There are a number of ways clients can mitigate these issues, and a defence-in-depth approach that uses a combination of techniques will provide the strongest security.
</t>
<t>
<list style="symbols">
<t>HTML can be filtered before rendering, stripping potentially malicious
content. Sanitising HTML correctly is tricky, and implementors are strongly recommended to use a well-tested library with a carefully vetted whitelist-only approach. New features with unexpected security characteristics may be added to HTML rendering engines in the future; a blacklist approach is likely to result in security issues.
<vspace blankLines="1" />
Subtle differences in parsing of HTML can introduce security flaws: to filter with 100% accuracy, you need to use the same parser that the HTML rendering engine will use.
</t>
<t>Encapsulating the message in an <spanx style="verb">&lt;iframe sandbox&gt;</spanx>, as defined in <xref target="HTML"/>,
Section 4.7.6, can help mitigate a number of risks. This will:
<list style="symbols">
<t>Disable JavaScript.</t>
<t>Disable form submission.</t>
<t>Prevent drawing outside of its bounds or conflicts between message CSS and interface CSS.</t>
<t>Establish a unique anonymous origin, separate to the containing origin.</t>
</list></t>

<t>A strong Content Security Policy (see &lt;https://www.w3.org/TR/CSP3/&gt;) can, among
other things, block JavaScript and the loading of external content should it manage to evade the filter.</t>

<t>The leakage of information in the Referer header can be mitigated with the
use of a referrer policy (see &lt;https://www.w3.org/TR/referrer-policy/&gt;).</t>

<t>A <spanx style="verb">crossorigin=anonymous</spanx> attribute on tags that load remote content can
prevent cookies from being sent.</t>

<t>If adding <spanx style="verb">target=_blank</spanx> to open links in new tabs, also add <spanx style="verb">rel=noopener</spanx>
to ensure the page that opens cannot change the URL in the original tab to
redirect the user to a phishing site.</t>
</list>
</t>
<t>As highly complex software components, HTML rendering engines increase the attack surface of a client considerably, especially when being used to process untrusted, potentially malicious content. Serious bugs have been found in image decoders, JavaScript engines, and HTML parsers in the past, which could lead to full system compromise. Clients using an engine should ensure they get the latest version and continue to incorporate any security patches released by the vendor.
</t>
</section>

<section anchor="multiple-part-display" title="Multiple Part Display">
<t>Messages may consist of multiple parts to be displayed sequentially as a body. Clients MUST render each part in isolation and MUST NOT concatenate the raw text values to render. Doing so may change the overall semantics of the message. If the client or server is decrypting a Pretty Good Privacy (PGP) or S/MIME encrypted part, concatenating with other parts may leak the decrypted text to an attacker, as described in <xref target="EFAIL"/>.
</t>
</section>

<section anchor="email-submission-1" title="Email Submission">
<t>SMTP submission servers <xref target="RFC6409"/> use a number of mechanisms to mitigate damage caused by compromised user accounts and end-user systems including rate limiting, anti-virus/anti-spam milters (mail filters), and other technologies. The technologies work better when they have more information about the client connection. If JMAP email submission is implemented as a proxy to an SMTP submission server, it is useful to communicate this information from the JMAP proxy to the submission server. The de facto XCLIENT extension to SMTP <xref target="XCLIENT"/> can be used to do this, but use of an authenticated channel is recommended to limit use of that extension to explicitly authorised proxies.
</t>
<t>JMAP servers that proxy to an SMTP submission server SHOULD allow use of
the submissions port <xref
target="RFC8314"/>. Implementation of a mechanism similar to SMTP XCLIENT is
strongly encouraged. While Simple Authentication and Security Layer (SASL)
PLAIN over TLS <xref target="RFC4616"/> is presently the
mandatory-to-implement mechanism for interoperability with SMTP submission
servers <xref target="RFC4954"/>, a JMAP submission proxy SHOULD implement and
prefer a stronger mechanism for this use case such as TLS client certificate
authentication with SASL EXTERNAL (<xref target="RFC4422"/>, Appendix A) or
Salted Challenge Response Authentication Mechanism (SCRAM) <xref
target="RFC7677"/>.
</t>
<t>In the event the JMAP server directly relays mail to SMTP servers in other administrative domains, implementation of the de facto <xref target="milter"/> protocol is strongly encouraged to integrate with third-party products that address security issues including anti-virus/anti-spam, reputation protection, compliance archiving, and data loss prevention. Proxying to a local SMTP submission server may be a simpler way to provide such security services.
</t>
</section>

<section anchor="partial-account-access" title="Partial Account Access">
<t>A user may only have permission to access a subset of the data that exists in an account. To avoid leaking unauthorised information, in such a situation, the server MUST treat any data the user does not have permission to access the same as if it did not exist.
</t>
<t>For example, suppose user A has an account with two Mailboxes, inbox and sent, but only shares the inbox with user B. In this case, when user B fetches Mailboxes for this account, the server MUST behave as though the sent Mailbox did not exist. Similarly, when querying or fetching Email objects, it MUST treat any messages that just belong to the sent Mailbox as though they did not exist. Fetching Thread objects MUST only return ids for Email objects the user has permission to access; if none, the Thread again MUST be treated the same as if it did not exist.
</t>
<t>If the server forbids a single account from having two identical messages, or two messages with the same Message-Id header field, a user with write access can use the error returned by trying to create/import such a message to detect whether it already exists in an inaccessible portion of the account.
</t>
</section>

<section anchor="permission-to-send-from-an-address" title="Permission to Send from an Address">
<t>In recent years, the email ecosystem has moved towards associating trust with the From address in the message <xref target="RFC5322"/>, particularly with schemes such as Domain-based Message Authentication, Reporting, and Conformance (DMARC) <xref target="RFC7489"/>.
</t>
<t>The set of Identity objects (see <xref target="identities"/>) in an account lets the client know which email addresses the user has permission to send from. Each email submission is associated with an Identity, and servers SHOULD reject submissions where the From header field of the message does not correspond to the associated Identity.
</t>
<t>The server MAY allow an exception to send an exact copy of an existing message received into the mail store to another address (otherwise known as &quot;redirecting&quot; or &quot;bouncing&quot;), although it is RECOMMENDED the server limit this to destinations the user has verified they also control.
</t>

<t>If the user attempts to create a new Identity object, the server MUST reject it with the appropriate error if the user does not have permission to use that email address to send from.
</t>
<t>The SMTP MAIL FROM address <xref target="RFC5321"/> is often confused with the From message header field <xref target="RFC5322"/>. The user generally only ever sees the address in the message header field, and this is the primary one to enforce. However, the server MUST also enforce appropriate restrictions on the MAIL FROM address <xref target="RFC5321"/> to stop the user from flooding a third-party address with bounces and non-delivery notices.
</t>
<t>The JMAP submission model provides separate errors for impermissible addresses in either context.
</t>
</section>
</section>

<section anchor="iana-considerations" title="IANA Considerations">

<section anchor="jmap-capability-registration-for-mail" title="JMAP Capability Registration for &quot;mail&quot;">
<t>IANA has registered the &quot;mail&quot; JMAP Capability as follows:
</t>
<t>Capability Name: urn:ietf:params:jmap:mail
</t>
<t>Specification document: this document
</t>
<t>Intended use: common
</t>
<t>Change Controller: IETF
</t>
<t>Security and privacy considerations: this document, <xref target="security-considerations"/>
</t>
</section>

<section anchor="jmap-capability-registration-for-submission" title="JMAP Capability Registration for &quot;submission&quot;">
<t>IANA has registered the &quot;submission&quot; JMAP Capability as follows:
</t>
<t>Capability Name: urn:ietf:params:jmap:submission
</t>
<t>Specification document: this document
</t>
<t>Intended use: common
</t>
<t>Change Controller: IETF
</t>
<t>Security and privacy considerations: this document, <xref target="security-considerations"/>
</t>
</section>

<section anchor="jmap-capability-registration-for-vacationresponse" title="JMAP Capability Registration for &quot;vacationresponse&quot;">
<t>IANA has registered the &quot;vacationresponse&quot; JMAP Capability as follows:
</t>
<t>Capability Name: urn:ietf:params:jmap:vacationresponse
</t>
<t>Specification document: this document
</t>
<t>Intended use: common
</t>
<t>Change Controller: IETF
</t>
<t>Security and privacy considerations: this document, <xref target="security-considerations"/>
</t>
</section>

<section anchor="imap-and-jmap-keywords-registry" title="IMAP and JMAP Keywords Registry">
<t>This document makes two changes to the IMAP keywords registry as defined in <xref target="RFC5788"/>.
</t>
<t>First, the name of the registry is changed to the &quot;IMAP and JMAP
Keywords&quot; registry.
</t>
<t>Second, a scope column is added to the template and registry indicating
whether a keyword applies to "IMAP-only", "JMAP-only", "both", or "reserved". All
keywords already in the IMAP keyword registry have been marked with a
scope of "both". The "reserved" status can be used to prevent future
registration of a name that would be confusing if registered.
Registration of keywords with scope "reserved" omit most fields in the
registration template (see registration of <spanx style="verb">$recent</spanx> below for an example); such registrations are intended to be infrequent.
</t>
<t>IMAP clients MAY silently ignore any keywords marked "JMAP-only" or
"reserved" in the event they appear in protocol. JMAP clients MAY silently
ignore any keywords marked "IMAP-only" or "reserved" in the event they appear
in protocol.
</t>
<t>New "JMAP-only" keywords are registered in the following subsections.
These keywords correspond to IMAP system keywords and are thus not
appropriate for use in IMAP. These keywords cannot be subsequently
registered for use in IMAP except via standards action.
</t>

<section anchor="registration-of-jmap-keyword-draft" title="Registration of JMAP Keyword &quot;$draft&quot;">
<t>This registers the "JMAP-only" keyword <spanx style="verb">$draft</spanx> in the &quot;IMAP and JMAP Keywords&quot; registry.
</t>
<t>Keyword name: $draft
</t>
<t>Scope: JMAP-only
</t>
<t>Purpose (description): This is set when the user wants to treat the
message as a draft the user is composing. This is the JMAP equivalent of the IMAP \Draft flag.
</t>
<t>Private or Shared on a server: BOTH
</t>
<t>Is it an advisory keyword or may it cause an automatic action:
Automatic. If the account has an IMAP mailbox marked with the \Drafts special
use attribute <xref target="RFC6154"/>, setting this flag MAY cause the message to appear in that
mailbox automatically. Certain JMAP computed values such as
<spanx style="verb">unreadEmails</spanx> will change as a result of changing this flag. In
addition, mail clients will typically present draft messages in a
composer window rather than a viewer window.
</t>
<t>When/by whom the keyword is set/cleared:
This is typically set by a JMAP client when referring to a draft
message. One model for draft Emails would result in clearing this flag
in an <spanx style="verb">EmailSubmission/set</spanx> operation with an <spanx style="verb">onSuccessUpdateEmail</spanx>
argument. In a mail store shared by JMAP and IMAP, this is also set and
cleared as necessary so it matches the IMAP \Draft flag.
</t>
<t>Related keywords: None
</t>
<t>Related IMAP/JMAP Capabilities: SPECIAL-USE <xref target="RFC6154"/>
</t>
<t>Security Considerations:
A server implementing this keyword as a shared keyword may disclose that
a user considers the message a draft message. This information would be
exposed to other users with read permission for the Mailbox keywords.
</t>
<t>Published specification: this document
</t>

<t>Person &amp; email address to contact for further information:
JMAP mailing list &lt;jmap@ietf.org&gt;
</t>
<t>Intended usage: COMMON
</t>
<t>Owner/Change controller: IESG
</t>
</section>

<section anchor="registration-of-jmap-keyword-seen" title="Registration of JMAP Keyword &quot;$seen&quot;">
<t>This registers the "JMAP-only" keyword <spanx style="verb">$seen</spanx> in the &quot;IMAP and JMAP
Keywords&quot; registry.
</t>
<t>Keyword name: $seen
</t>
<t>Scope: JMAP-only
</t>
<t>Purpose (description): This is set when the user wants to treat the
message as read. This is the JMAP equivalent of the IMAP \Seen flag.
</t>
<t>Private or Shared on a server: BOTH
</t>
<t>Is it an advisory keyword or may it cause an automatic action:
Advisory. However, certain JMAP computed values such as <spanx style="verb">unreadEmails</spanx>
will change as a result of changing this flag.
</t>
<t>When/by whom the keyword is set/cleared:
This is set by a JMAP client when it presents the message content to the
user; clients often offer an option to clear this flag. In a mail store
shared by JMAP and IMAP, this is also set and cleared as necessary so it
matches the IMAP \Seen flag.
</t>
<t>Related keywords: None
</t>
<t>Related IMAP/JMAP Capabilities: None
</t>
<t>Security Considerations:
A server implementing this keyword as a shared keyword may disclose that
a user considers the message to have been read. This information would be
exposed to other users with read permission for the Mailbox keywords.
</t>
<t>Published specification: this document
</t>
<t>Person &amp; email address to contact for further information:
JMAP mailing list &lt;jmap@ietf.org&gt;
</t>
<t>Intended usage: COMMON
</t>
<t>Owner/Change controller: IESG
</t>
</section>

<section anchor="registration-of-jmap-keyword-flagged" title="Registration of JMAP Keyword &quot;$flagged&quot;">
<t>This registers the "JMAP-only" keyword <spanx style="verb">$flagged</spanx> in the &quot;IMAP and JMAP
Keywords&quot; registry.
</t>
<t>Keyword name: $flagged
</t>
<t>Scope: JMAP-only
</t>
<t>Purpose (description): This is set when the user wants to treat the
message as flagged for urgent/special attention. This is the JMAP
equivalent of the IMAP \Flagged flag.
</t>
<t>Private or Shared on a server: BOTH
</t>
<t>Is it an advisory keyword or may it cause an automatic action:
Automatic. If the account has an IMAP mailbox marked with the \Flagged special
use attribute <xref target="RFC6154"/>, setting this flag MAY cause the message to appear in that mailbox automatically.
</t>
<t>When/by whom the keyword is set/cleared:
JMAP clients typically allow a user to set/clear this flag as desired.
In a mail store shared by JMAP and IMAP, this is also set and cleared as
necessary so it matches the IMAP \Flagged flag.
</t>
<t>Related keywords: None
</t>
<t>Related IMAP/JMAP Capabilities: SPECIAL-USE <xref target="RFC6154"/>
</t>
<t>Security Considerations:
A server implementing this keyword as a shared keyword may disclose that
a user considers the message as flagged for urgent/special attention.
This information would be exposed to other users with read permission
for the Mailbox keywords.
</t>
<t>Published specification: this document
</t>
<t>Person &amp; email address to contact for further information:
JMAP mailing list &lt;jmap@ietf.org&gt;
</t>
<t>Intended usage: COMMON
</t>
<t>Owner/Change controller: IESG
</t>
</section>

<section anchor="registration-of-jmap-keyword-answered" title="Registration of JMAP Keyword &quot;$answered&quot;">
<t>This registers the "JMAP-only" keyword <spanx style="verb">$answered</spanx> in the &quot;IMAP and JMAP
Keywords&quot; registry.
</t>
<t>Keyword name: $answered
</t>
<t>Scope: JMAP-only
</t>
<t>Purpose (description): This is set when the message has been answered.
</t>
<t>Private or Shared on a server: BOTH
</t>
<t>Is it an advisory keyword or may it cause an automatic action:
Advisory.
</t>
<t>When/by whom the keyword is set/cleared:
JMAP clients typically set this when submitting a reply or answer to the
message. It may be set by the <spanx style="verb">EmailSubmission/set</spanx> operation with an
<spanx style="verb">onSuccessUpdateEmail</spanx> argument. In a mail store shared by JMAP and IMAP,
this is also set and cleared as necessary so it matches the IMAP
\Answered flag.
</t>
<t>Related keywords: None
</t>
<t>Related IMAP/JMAP Capabilities: None
</t>
<t>Security Considerations:
A server implementing this keyword as a shared keyword may disclose that
a user has replied to a message.
This information would be exposed to other users with read permission
for the Mailbox keywords.
</t>
<t>Published specification: this document
</t>
<t>Person &amp; email address to contact for further information:
JMAP mailing list &lt;jmap@ietf.org&gt;
</t>
<t>Intended usage: COMMON
</t>
<t>Owner/Change controller: IESG
</t>
</section>

<section anchor="registration-of-recent-keyword" title="Registration of &quot;$recent&quot; Keyword">
<t>This registers the keyword <spanx style="verb">$recent</spanx> in the &quot;IMAP and JMAP Keywords&quot; registry.
</t>
<t>Keyword name: $recent
</t>
<t>Scope: reserved
</t>
<t>Purpose (description): This keyword is not used to avoid confusion with
the IMAP \Recent system flag.
</t>
<t>Published specification: this document
</t>
<t>Person &amp; email address to contact for further information:
JMAP mailing list &lt;jmap@ietf.org&gt;
</t>
<t>Owner/Change controller: IESG
</t>
</section>
</section>

<section anchor="imap-mailbox-name-attributes-registry" title="IMAP Mailbox Name Attributes Registry">
<section anchor="registration-of-inbox-role" title="Registration of &quot;inbox&quot; Role">
<t>This registers the "JMAP-only" &quot;inbox&quot; attribute in the &quot;IMAP Mailbox Name Attributes&quot; registry, as established in <xref target="RFC8457"/>.
</t>
<t>Attribute Name: Inbox
</t>
<t>Description: New mail is delivered here by default.
</t>
<t>Reference: This document, <xref target="registration-of-inbox-role"/>
</t>
<t>Usage Notes: JMAP only
</t>
</section>
</section>

<section anchor="jmap-error-codes-registry" title="JMAP Error Codes Registry">
<t>The following subsections register several new error codes in the "JMAP
Error Codes" registry, as defined in <xref target="RFC8620"/>.
</t>

<section anchor="mailboxhaschild" title="mailboxHasChild">
<t>JMAP Error Code: mailboxHasChild
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="mailboxset"/>
</t>
<t>Description: The Mailbox still has at least one child Mailbox. The client MUST remove these before it can delete the parent Mailbox.
</t>
</section>

<section anchor="mailboxhasemail" title="mailboxHasEmail">
<t>JMAP Error Code: mailboxHasEmail
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="mailboxset"/>
</t>
<t>Description: The Mailbox has at least one message assigned to it, and the onDestroyRemoveEmails argument was false.
</t>
</section>

<section anchor="blobnotfound" title="blobNotFound">
<t>JMAP Error Code: blobNotFound
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="emailset"/>
</t>
<t>Description: At least one blob id referenced in the object doesn't exist.
</t>
</section>

<section anchor="toomanykeywords" title="tooManyKeywords">
<t>JMAP Error Code: tooManyKeywords
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="emailset"/>
</t>
<t>Description: The change to the Email's keywords would exceed a server-defined maximum.
</t>
</section>

<section anchor="toomanymailboxes" title="tooManyMailboxes">
<t>JMAP Error Code: tooManyMailboxes
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="emailset"/>
</t>
<t>Description: The change to the set of Mailboxes that this Email is in would exceed a server-defined maximum.
</t>
</section>

<section anchor="invalidemail" title="invalidEmail">
<t>JMAP Error Code: invalidEmail
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="emailsubmissionset"/>
</t>
<t>Description: The Email to be sent is invalid in some way.
</t>
</section>

<section anchor="toomanyrecipients" title="tooManyRecipients">
<t>JMAP Error Code: tooManyRecipients
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="emailsubmissionset"/>
</t>
<t>Description: The envelope <xref target="RFC5321"/> (supplied or generated) has more recipients than the server allows.
</t>
</section>

<section anchor="norecipients" title="noRecipients">
<t>JMAP Error Code: noRecipients
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="emailsubmissionset"/>
</t>
<t>Description: The envelope <xref target="RFC5321"/> (supplied or generated) does not have any rcptTo email addresses.
</t>
</section>

<section anchor="invalidrecipients" title="invalidRecipients">
<t>JMAP Error Code: invalidRecipients
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="emailsubmissionset"/>
</t>
<t>Description:  The rcptTo property of the envelope <xref target="RFC5321"/> (supplied or generated) contains at least one rcptTo value that is not a valid email address for sending to.
</t>
</section>

<section anchor="forbiddenmailfrom" title="forbiddenMailFrom">
<t>JMAP Error Code: forbiddenMailFrom
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="emailsubmissionset"/>
</t>
<t>Description: The server does not permit the user to send a message
  with this envelope From address <xref target="RFC5321"/>.
</t>
</section>

<section anchor="forbiddenfrom" title="forbiddenFrom">
<t>JMAP Error Code: forbiddenFrom
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, Sections <xref target="identityset" format="counter"/> and <xref target="emailsubmissionset" format="counter"/>
</t>
<t>Description: The server does not permit the user to send a message with the From header field <xref target="RFC5322"/> of the message to be sent.
</t>
</section>

<section anchor="forbiddentosend" title="forbiddenToSend">
<t>JMAP Error Code: forbiddenToSend
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, <xref target="emailsubmissionset"/>
</t>
<t>Description: The user does not have permission to send at all right now.
</t>
</section>
</section>
</section>

</middle>
<back>
<references title="Normative References">
<reference anchor='HTML' target='https://www.w3.org/TR/html52/'>
  <front>
    <title>HTML 5.2</title>
    <author initials='S.' surname='Faulkner' fullname='Steve Faulkner'>
        <organization>The Paciello Group</organization>
    </author>
    <author initials='A.' surname='Eicholz' fullname='Arron Eicholz'>
        <organization>Microsoft</organization>
    </author>
    <author initials='T.' surname='Leithead' fullname='Travis Leithead'>
        <organization>Microsoft</organization>
    </author>
    <author initials='A.' surname='Danilo' fullname='Alex Danilo'>
        <organization>Google</organization>
    </author>
    <author initials='S.' surname='Moon' fullname='Sangwhan Moon'>
        <organization>Invited Expert</organization>
    </author>
    <date month="December" year='2017'/>
  </front>
<seriesInfo name='World Wide Web Consortium Recommendation' value='REC-html52-20171214' />
</reference>

<!-- draft-ietf-jmap-core-17 (RFC-to-be 8620) -->
<reference anchor='RFC8620' target='https://www.rfc-editor.org/info/rfc8620'>
<front>
<title>The JSON Meta Application Protocol</title>
<author initials='N' surname='Jenkins' fullname='Neil Jenkins'>
    <organization />
</author>
<author initials='C' surname='Newman' fullname='Chris Newman'>
    <organization />
</author>
<date month='June' year='2019' />
</front>
<seriesInfo name='RFC' value='8620' />
<seriesInfo name='DOI' value='10.17487/RFC8620' />
</reference>

<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.1870.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2045.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2047.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2231.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2369.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2392.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2557.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2852.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3282.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3461.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3463.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3464.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3834.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4314.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4422.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4616.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4865.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4954.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5198.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5248.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5256.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5321.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5322.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5788.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6154.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6409.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6532.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6533.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6710.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7677.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8098.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8314.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8457.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8474.xml"?>
</references>
<references title="Informative References">
<reference anchor='EFAIL' target='https://www.usenix.org/system/files/conference/usenixsecurity18/sec18-poddebniak.pdf'>
    <front>
    <title>Efail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration Channels</title>
    <author initials='D.' surname='Poddebniak' fullname='Damian Poddebniak'>
      <organization>M?nster University of Applied Sciences</organization>
    </author>
    <author initials='C.' surname='Dresen' fullname='Christian Dresen'>
      <organization>M?nster University of Applied Sciences</organization>
    </author>
    <author initials='J.' surname='Mueller' fullname='Jens Mueller'>
      <organization>Ruhr University Bochum</organization>
    </author>
    <author initials='F.' surname='Ising' fullname='Fabian Ising'>
      <organization>M?nster University of Applied Sciences</organization>
    </author>
    <author initials='S.' surname='Schinzel' fullname='Sebastian Schinzel'>
      <organization>M?nster University of Applied Sciences</organization>
    </author>
    <author initials='S.' surname='Friedberger' fullname='Simon Friedberger'>
      <organization>NXP Semiconductors</organization>
    </author>
    <author initials='J.' surname='Somorovsky' fullname='Juraj Somorovsky'>
      <organization>Ruhr University Bochum</organization>
    </author>
    <author initials='J.' surname='Schwenk' fullname='Joerg Schwenk'>
      <organization>Ruhr University Bochum</organization>
    </author>
    <date month='August' year='2018'/>
    </front>
</reference>

<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3501.xml"?>
<?rfc include="http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7489.xml"?>

<reference anchor='XCLIENT' target='http://www.postfix.org/XCLIENT_README.html'>
    <front>
    <title>Postfix XCLIENT Howto</title>
    <author>
      <organization>Postfix</organization>
    </author>
    <date year='2019'/>
    </front>
</reference>

<reference anchor='milter' target='http://www.postfix.org/MILTER_README.html'>
    <front>
    <title>Postfix before-queue Milter support</title>
    <author>
      <organization>Postfix</organization>
    </author>
    <date year='2019'/>
    </front>
</reference>
</references>

</back>
</rfc>
