JMAP N. Jenkins
Internet-Draft FastMail
Updates: 5788 (if approved) May 9, 2018
Intended status: Standards Track
Expires: November 10, 2018

JMAP for Mail
draft-ietf-jmap-mail-05

Abstract

This document specifies a data model for synchronising email data with a server using JMAP.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

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

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on November 10, 2018.

Copyright Notice

Copyright (c) 2018 IETF Trust and the persons identified as the document authors. All rights reserved.

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.


Table of Contents

1. Introduction

JMAP <https://tools.ietf.org/html/draft-ietf-jmap-core-03> 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.

This specification defines a data model for synchronising mail between a client and a server using JMAP.

1.1. Notational Conventions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119].

The underlying format used for this specification is I-JSON ([RFC7493]). Consequently, the terms "object" and "array" as well as the four primitive types (strings, numbers, booleans, and null) are to be interpreted as described in Section 1 of [RFC7159]. Unless otherwise noted, all the property names and values are case sensitive.

Some examples in this document contain "partial" JSON documents used for illustrative purposes. In these examples, three periods "..." are used to indicate a portion of the document that has been removed for compactness.

Types signatures are given for all JSON objects in this document. The following conventions are used:

Object properties may also have a set of attributes defined along with the type signature. These have the following meanings:

1.2. The Date datatypes

Where Date is given as a type, it means a string in [RFC3339] date-time format. To ensure a normalised form, the time-secfrac MUST always be omitted and any letters in the string (e.g. "T" and "Z") MUST be upper-case. For example, "2014-10-30T14:12:00+08:00".

Where UTCDate is given as a type, it means a Date where the time-offset component MUST be Z (i.e. it must be in UTC time). For example, "2014-10-30T06:12:00Z".

1.3. Terminology

The same terminology is used in this document as in the core JMAP specification.

1.4. Addition to the capabilities object

The capabilities object is returned as part of the standard JMAP Session object; see the JMAP spec. Servers supporting this specification MUST add a property called urn:ietf:params:jmap:mail to the capabilities object. The value of this property is an object which MUST contain the following information on server capabilities:

1.5. Data profile name

The data profile name for the set of types defined in this specification is mail.

The JMAP Session object has an accounts property with the set of accounts to which the user has access. Any account that contains data of the types defined in this specification MUST include the string "mail" in the hasDataFor property of the account object.

2. Mailboxes

A mailbox represents a named set of emails. This is the primary mechanism for organising emails 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.

For compatibility with IMAP, an email MUST belong to one or more mailboxes. The email id does not change if the email changes mailboxes.

A Mailbox object has the following properties:

The Trash mailbox (that is a mailbox with role == "trash") MUST be treated specially for the purpose of unread counts:

  1. Emails that are only in the Trash (and no other mailbox) are ignored when calculating the unreadThreads count of other mailboxes.
  2. Emails that are not in the Trash are ignored when calculating the unreadThreads count for the Trash mailbox.

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.

So for example, suppose you have an account where the entire contents is a single conversation with 2 emails: an unread email in the Trash and a read email in the Inbox. The unreadThreads count would be 1 for the Trash and 0 for the Inbox.

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 the Trash mailbox and leave it in the other mailbox).

The following JMAP methods are supported:

2.1. Mailbox/get

Standard /get method. The ids argument may be null to fetch all at once.

2.2. Mailbox/changes

Standard /changes method, but with one extra argument to the response:

Since counts frequently change but the rest of the mailboxes state for most use cases changes rarely, the server can help the client optimise data transfer by keeping track of changes to email/thread counts separately to other state changes. The changedProperties array may be used directly via a result reference in a subsequent Mailboxe/get call in a single request.

2.3. Mailbox/query

Standard /query method.

A FilterCondition object has the following properties, any of which may be omitted:

A Mailbox object matches the filter if and only if all of the given conditions given match. If zero properties are specified, it is automatically true for all objects.

The following properties MUST be supported for sorting:

2.4. Mailbox/queryChanges

Standard /queryChanges method.

2.5. Mailbox/set

Standard /set method, but with the following additional argument:

The following extra SetError types are defined:

For destroy:

3. Threads

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.

The JMAP spec does not require the server to use any particular algorithm for determining whether two emails belong to the same thread, however there is a recommended algorithm in the implementation guide.

If emails are delivered out of order for some reason, a user may receive two emails in the same thread but without headers that associate them with each other. The arrival of a third email in the thread may provide the missing references to join them all together into a single thread. Since the threadId 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 threadId.

A Thread object has the following properties:

The following JMAP methods are supported:

3.1. Thread/get

Standard /get method.

3.1.1. Example

Request:

[ "Thread/get", {
  "ids": ["f123u4", "f41u44"],
}, "#1" ]

with response:

[ "Thread/get", {
  "accountId": "acme",
  "state": "f6a7e214",
  "list": [
    {
      "id": "f123u4",
      "emailIds": [ "eaa623", "f782cbb"]
    },
    {
      "id": "f41u44",
      "emailIds": [ "82cf7bb" ]
    }
  ],
  "notFound": null
}, "#1" ]

3.2. Thread/changes

Standard /changes method.

4. Emails

The Email object is a representation of an [RFC5322] message, which allows clients to avoid the complexities of MIME parsing, transport encoding and character encoding.

4.1. Properties of the Email object

Broadly, a message consists of two parts: a list of header fields, then a body. The body is normally a MIME-encoded set of documents in a tree structure. The JMAP Email object 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.

Due to the number of properties involved, the set of Email properties is specified over the following three sub-sections.

4.1.1. Metadata

These properties represent metadata about the [RFC5322] message, and are not derived from parsing the message itself.

4.1.2. Header fields

These properties are derived from the [RFC5322] and [RFC6532] message header fields. All header fields may be fetched in a raw form. Some headers may also be fetched in a parsed form. The structured form that may be fetched depends on the header. The following forms are defined:

Any syntactically correct [RFC2047] encoded sections with a known encoding MUST be decoded, following the same rules as for the Text form. Any [RFC6532] UTF-8 values MUST be decoded.

Parsing SHOULD be best-effort in the face of invalid structure to accommodate invalid messages and semi-complete drafts. EmailAddress objects MAY have an email property that does not conform to the addr-spec form (for example, may not contain an @ symbol).

To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the following header fields:

To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the following header fields:

To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the following header fields:

To prevent obviously nonsense behaviour, which can lead to interoperability issues, this form may only be fetched or set for the following header fields:

The following low-level Email property is specified for complete access to the header data of the message:

In addition, the client may request/send properties representing individual header fields of the form:

header:{header-field-name}

Where {header-field-name} means any series of one or more printable ASCII characters (i.e. characters that have values between 33 and 126, inclusive), except colon. The property may also have the following suffixes:

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 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 the empty array if requesting :all.

As a simple example, if the client requests a property called header:subject, this means find the last header field in the message named "subject" (matched case-insensitively) and return the value in Raw form, or null if no header of this name is found.

For a more complex example, consider the client requesting a property called header:Resent-To:asAddresses:all. This means:

  1. Find all header fields named Resent-To (matched case-insensitively).
  2. For each instance parse the header field value in the Addresses form.
  3. The result is of type EmailAddress[][] – each item in the array corresponds to the parsed value (which is itself an array) of the Resent-To header field instance.

The following convenience properties are also specified for the Email object:

4.1.3. Body parts

These properties are derived from the [RFC5322] message body and its [RFC2045] MIME entities.

A EmailBodyPart object has the following properties:

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. header:Content-Type.

The following Email properties are specified for access to the body data of the message:

MIME structures are arbitrary nested trees of documents, but the majority of email clients present a model of an email body (normally plain text or HTML), with a set of attachments. Interpreting the MIME structure to form this flat model represents considerable difficulty and causes inconsistency between clients. Therefore in addition to the bodyStructure property, which gives the full tree, the Email object contains 4 alternate properties with flat lists of body parts:

Because MIME allows for multiple representations of the same data (using multipart/alternative), there is a textBody property (which prefers a plain text representation) and an htmlBody 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.

The bodyValues property allows for clients to fetch the value of text parts directly without having to do a second request for the blob, and 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.

The exact algorithm for decomposing bodyStructure into textBody, htmlBody, attachedEmails and attachedFiles 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:

function isInlineMediaType ( type ) {
  return type.startsWith( 'image/' ) ||
         type.startsWith( 'audio/' ) ||
         type.startsWith( 'video/' );
}

function parseStructure ( parts, multipartType, inAlternative,
        htmlBody, textBody, attachedEmails, attachedFiles ) {

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

    for ( let i = 0; i < 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" &&
            // Must be one of the allowed body types
            ( part.type == "text/plain" ||
              part.type == "text/html" ||
              isInlineMediaType( part.type ) &&
            // 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" &&
                ( isInlineMediaType( part.type ) || !part.name ) ) );

        if ( isMultipart ) {
            let subMultiType = part.type.split( '/' )[1];
            parseStructure( part.subParts, subMultiType,
                inAlternative || ( subMultiType == 'alternative' ),
                htmlBody, textBody, attachedEmails, attachedFiles );
        } else if ( isInline ) {
            if ( multipartType == 'alternative' ) {
                switch ( part.type ) {
                case 'text/plain':
                    textBody.push( part );
                    break;
                case 'text/html':
                    htmlBody.push( part );
                    break;
                default:
                    attachedFiles.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 ) &&
                    isInlineMediaType( part.type ) {
                attachedFiles.push( part );
            }
        } else if ( part.type == 'message/rfc822' ||
                    part.type == 'message/global' ) {
            attachedEmails.push( part );
        } else {
            attachedFiles.push( part );
        }

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

// Usage:
let htmlBody = [];
let textBody = [];
let attachedEmails = [];
let attachedFiles = [];

parseStructure( [ bodyStructure ], 'mixed', false,
    htmlBody, textBody, attachedEmails, attachedFiles );

For instance, consider a message with both text and html versions that's then gone through a list software manager that attaches a header/footer. It might have a MIME structure something like:

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

In this case, the above algorithm would decompose this to:

textBody => [ A, B, C, D, K ]
htmlBody => [ A, E, K ]
attachedEmails: [ J ]
attachedFiles => [ C, F, G, H ]

4.2. Email/get

Standard /get method, with the following additional arguments:

If the standard properties argument is omitted or null, the following default MUST be used instead of "all" properties:

[ "id", "blobId", "threadId", "mailboxIds", "keywords", "size", "receivedAt", "messageId", "inReplyTo", "references", "sender", "from", "to", "cc", "bcc", "replyTo", "subject", "sentAt", "hasAttachment", "preview", "bodyValues", "textBody", "htmlBody", "attachedFiles", "attachedEmails" ]

The following properties are expected to be fast to fetch in a quality implementation:

Clients SHOULD take care when fetching any other properties, as there may be significantly longer latency in fetching and returning the data.

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. header:From:asDate) MUST result in the method call being rejected with an invalidArguments error.

Where a specific header is requested as a property, the capitalization of the property name in the response MUST be identical to that used in the request.

4.2.1. Example

Request:

["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"]

and response:

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

4.3. Email/changes

Standard /changes method.

4.4. Email/query

Standard /query method, but with the following additional arguments:

4.4.1. Filtering

A FilterCondition object has the following properties, any of which may be omitted:

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

The exact semantics for matching String fields is deliberately not defined to allow for flexibility in indexing implementation, subject to the following:

4.4.2. Sorting

The following properties MUST be supported for sorting:

The following properties SHOULD be supported for sorting:

The server MAY support sorting based on other properties as well. A client can discover which properties are supported by inspecting the server's capabilities object (see section 1).

Example sort:

[{
  "property": "someInThreadHaveKeyword",
  "keyword": "$flagged",
  "isAscending": false,
}, {
  "property": "subject",
  "collation": "i;ascii-casemap"
}, {
  "property": "receivedAt",
  "isAscending": false,
}]

This would sort emails in flagged threads first (the thread is considered flagged if any email within it is flagged), and then in subject order, then newest first for messages with the same subject. If two emails have both identical flagged status, subject and date, the order is server-dependent but must be stable.

4.4.3. Thread collapsing

When collapseThreads == 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 once in the threadIds list of the result, at the position of the first email in the list that belongs to the thread.

4.4.4. Response

The response has the following additional argument:

4.5. Email/queryChanges

Standard /queryChanges method, with the following additional arguments:

The response has the following additional argument:

4.6. Email/set

Standard /set method. The Email/set method encompasses:

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 RFC5322 email to create is unambiguous, the following constraints apply to Email objects submitted for creation:

Creation attempts that violate any of this SHOULD be rejected with an invalidProperties 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.

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 [RFC5322] section 3.6.4, and a Date header field in conformance with section 3.6.1.

The final RFC5322 email generated may be invalid. For example, if it is a half-finished draft, the "To" field may data that does not currently conform to the required syntax for this header field. The message will be checked for strict conformance when submitted for sending (see the EmailSubmission object description).

Destroying an email removes it from all mailboxes to which it belonged. To just delete an email to trash, simply change the mailboxIds property so it is now in the mailbox with role == "trash", and remove all other mailbox ids.

When emptying the trash, clients SHOULD NOT destroy emails which are also in a mailbox other than trash. For those emails, they SHOULD just remove the Trash mailbox from the email.

For successfully created Email objects, the created response MUST contain the id, blobId, threadId and size properties of the object.

The following extra SetError types are defined:

For create:

For create and update:

4.7. Email/import

The Email/import method adds [RFC5322] messages to a user's set of emails. The messages must first be uploaded as a file using the standard upload mechanism. It takes the following arguments:

An EmailImport object has the following properties:

Each email to import is considered an atomic unit which may succeed or fail individually. Importing successfully creates a new email object from the data reference by the blobId and applies the given mailboxes, keywords and receivedAt date.

The server MAY forbid two email objects with the same exact [RFC5322] content, or even just with the same [RFC5322] Message-ID, to coexist within an account. In this case, it MUST reject attempts to import an email considered a duplicate with an alreadyExists SetError. An emailId property of type String MUST be included on the error object with the id of the existing email.

If the blobId, mailboxIds, or keywords properties are invalid (e.g. missing, wrong type, id not found), the server MUST reject the import with an invalidProperties SetError.

If the email cannot be imported because it would take the account over quota, the import should be rejected with a maxQuotaReached SetError.

If the blob referenced is not a valid [RFC5322] message, the server MAY modify the message to fix errors (such as removing NUL octets or fixing invalid headers). If it does this, the blobId on the response MUST represent the new representation and therefore be different to the blobId on the EmailImport object. Alternatively, the server MAY reject the import with an invalidEmail SetError.

The response has the following arguments:

4.8. Email/copy

The only way to move messages between two different accounts is to copy them using the Email/copy method, then once the copy has succeeded, delete the original. The onSuccessDestroyOriginal argument allows you to try to do this in one method call, however note that the two different actions are not atomic, and so it is possible for the copy to succeed but the original not to be destroyed for some reason.

The Email/copy method takes the following arguments:

An EmailCopy object has the following properties:

The server MAY forbid two email objects with the same exact [RFC5322] content, or even just with the same [RFC5322] Message-ID, to coexist within an account. If duplicates are allowed though, the "from" account may be the same as the "to" account to copy emails within an account.

Each email copy is considered an atomic unit which may succeed or fail individually. Copying successfully MUST create a new email object, with separate ids and mutable properties (e.g. mailboxes and keywords) to the original email.

The response has the following arguments:

The SetError may be any of the standard set errors that may be returned for a create. The following extra SetError type is also defined:

alreadyExists: The server forbids duplicates and the email already exists in the target account. An emailId property of type String MUST be included on the error object with the id of the existing email.

The following additional errors may be returned instead of the Email/copy response:

fromAccountNotFound: A fromAccountId was explicitly included with the request, but it does not correspond to a valid account.

toAccountNotFound: A toAccountId was explicitly included with the request, but it does not correspond to a valid account.

fromAccountNotSupportedByMethod: The fromAccountId given corresponds to a valid account, but does not contain any mail data.

toAccountNotSupportedByMethod: The toAccountId given corresponds to a valid account, but does not contain any mail data.

4.9. Email/parse

This method allows you to parse blobs as [RFC5322] messages to get Email objects. The following metadata properties on the Email objects will be null if requested:

The threadId 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.

The Email/parse method takes the following arguments:

The response has the following arguments:

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. header:From:asDate) MUST result in the method call being rejected with an invalidArguments error.

Where a specific header is requested as a property, the capitalization of the property name in the response MUST be identical to that used in the request.

5. Email submission

An EmailSubmission object represents the submission of an email for delivery to one or more recipients. It has the following properties:

550-5.7.1 Our system has detected that this message is
550 5.7.1 likely spam, sorry.
550 5.7.1 Our system has detected that this message is likely spam, sorry.

JMAP servers MAY choose not to expose DSN and MDN responses as Email objects if they correlate to a EmailSubmission object. It SHOULD only do this if it exposes them in the dsnBlobIds and mdnblobIds fields instead, and expects the user to be using clients capable of fetching and displaying delivery status via the EmailSubmission object.

For efficiency, a server MAY destroy EmailSubmission objects a certain amount of time after the email is successfully sent or it has finished retrying sending the email. 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.

The following JMAP methods are supported:

5.1. EmailSubmission/get

Standard /get method.

5.2. EmailSubmission/changes

Standard /changes method.

5.3. EmailSubmission/query

Standard /query method.

A FilterCondition object has the following properties, any of which may be omitted:

A EmailSubmission object matches the filter if and only if all of the given conditions given match. If zero properties are specified, it is automatically true for all objects.

The following properties MUST be supported for sorting:

5.4. EmailSubmission/queryChanges

Standard /queryChanges method.

5.5. EmailSubmission/set

Standard /set method, with the following two extra arguments:

A single implicit Email/set call MUST be made after all EmailSubmission create/update/destroy requests have been processed to perform any changes requested in these two arguments. The response to this MUST be returned after the EmailSubmission/set response.

An email is sent by creating a EmailSubmission object. When processing each create, the server must check that the email is valid, and the user has sufficient authorization to send it. If the creation succeeds, the email will be sent to the recipients given in the envelope rcptTo parameter. The server MUST remove any Bcc header present on the email during delivery. The server MAY add or remove other headers from the submitted email, or make further alterations in accordance with the server's policy during delivery.

If the referenced email is destroyed at any point after the EmailSubmission object is created, this MUST NOT change the behaviour of the email submission (i.e. it does not cancel a future send).

Similarly, destroying a EmailSubmission object MUST NOT affect the deliveries it represents. It purely removes the record of the email submission. The server MAY automatically destroy EmailSubmission objects after a certain time or in response to other triggers, and MAY forbid the client from manually destroying EmailSubmission objects.

The following extra SetError types are defined:

For create:

For update:

6. Identities

An Identity object stores information about an email address (or domain) the user may send from. It has the following properties:

See the "Addresses" header form description in the Email object for the definition of EmailAddress.

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

The following JMAP methods are supported:

6.1. Identity/get

Standard /get method. The ids argument may be null to fetch all at once.

6.2. Identity/changes

Standard /changes method.

6.3. Identity/set

Standard /set method. The following extra SetError types are defined:

For create:

For destroy:

7. Search snippets

When doing a search on a String property, the client may wish to show the relevant section of the body that matches the search as a preview instead of the beginning of the message, and to highlight any matching terms in both this and the subject of the email. Search snippets represent this data.

A SearchSnippet object has the following properties:

It is server-defined what is a relevant section of the body for preview. If the server is unable to determine search snippets, it MUST return null for both the subject, preview and attachments properties.

Note, unlike most data types, a SearchSnippet DOES NOT have a property called id.

The following JMAP method is supported:

7.1. SearchSnippet/get

To fetch search snippets, make a call to SearchSnippet/get. It takes the following arguments:

The response has the following arguments:

Since snippets are only based on immutable properties, there is no state string or update mechanism needed.

The following additional errors may be returned instead of the searchSnippets response:

requestTooLarge: Returned if the number of emailIds requested by the client exceeds the maximum number the server is willing to process in a single method call.

unsupportedFilter: Returned if the server is unable to process the given filter for any reason.

8. Vacation response

The VacationResponse object represents the state of vacation-response related settings for an account. It has the following properties:

The following JMAP methods are supported:

8.1. VacationResponse/get

Standard /get method.

There MUST only be exactly one VacationResponse object in an account. It MUST have the id "singleton".

8.2. VacationResponse/set

Standard /set method.

9. Security considerations

All security considerations of JMAP {TODO: insert RFC ref} apply to this specification.

9.1. EmailBodyPart value

Service providers typically perform security filtering on incoming email and it's important 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 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 mailbox host.

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.

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 to rescan the truncated value for malicious content before returning it.

9.2. HTML email display

HTML message bodies provide richer formatting for emails but present a number of security challenges, especially when embedded in a webmail context in combination with interface HTML. Clients that render HTML email should make careful consideration of the potential risks, including:

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.

Subtle differences in parsing of HTML can introduce security flaws: to filter with 100% accurately you need to use the same parser when sanitizing that the HTML rendering engine will use.

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.

9.3. Email submission

SMTP submission servers [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 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 can be used to do this, but use of an authenticated channel is recommended to limit use of that extension to explicitly authorized proxies. JMAP servers that proxy to an SMTP Submission server SHOULD allow use of the submissions port [RFC8314] and SHOULD implement SASL PLAIN over TLS [RFC4616] and/or TLS client certificate authentication with SASL EXTERNAL [RFC4422] appendix A. Implementation of a mechanism similar to SMTP XCLIENT is strongly encouraged.

In the event the JMAP server directly relays mail to SMTP servers in other administrative domains, then implementation of the de-facto milter protocol is strongly encouranged 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.

10. Normative References

[RFC1870] Klensin, J., Freed, N. and K. Moore, "SMTP Service Extension for Message Size Declaration", STD 10, RFC 1870, DOI 10.17487/RFC1870, November 1995.
[RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, DOI 10.17487/RFC2045, November 1996.
[RFC2047] Moore, K., "MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text", RFC 2047, DOI 10.17487/RFC2047, November 1996.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
[RFC2231] Freed, N. and K. Moore, "MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations", RFC 2231, DOI 10.17487/RFC2231, November 1997.
[RFC2369] Neufeld, G. and J. Baer, "The Use of URLs as Meta-Syntax for Core Mail List Commands and their Transport through Message Header Fields", RFC 2369, DOI 10.17487/RFC2369, July 1998.
[RFC2557] Palme, J., Hopmann, A. and N. Shelness, "MIME Encapsulation of Aggregate Documents, such as HTML (MHTML)", RFC 2557, DOI 10.17487/RFC2557, March 1999.
[RFC2852] Newman, D., "Deliver By SMTP Service Extension", RFC 2852, DOI 10.17487/RFC2852, June 2000.
[RFC3282] Alvestrand, H., "Content Language Headers", RFC 3282, DOI 10.17487/RFC3282, May 2002.
[RFC3339] Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002.
[RFC3461] Moore, K., "Simple Mail Transfer Protocol (SMTP) Service Extension for Delivery Status Notifications (DSNs)", RFC 3461, DOI 10.17487/RFC3461, January 2003.
[RFC3463] Vaudreuil, G., "Enhanced Mail System Status Codes", RFC 3463, DOI 10.17487/RFC3463, January 2003.
[RFC3464] Moore, K. and G. Vaudreuil, "An Extensible Message Format for Delivery Status Notifications", RFC 3464, DOI 10.17487/RFC3464, January 2003.
[RFC3798] Hansen, T. and G. Vaudreuil, "Message Disposition Notification", RFC 3798, DOI 10.17487/RFC3798, May 2004.
[RFC4422] Melnikov, A. and K. Zeilenga, "Simple Authentication and Security Layer (SASL)", RFC 4422, DOI 10.17487/RFC4422, June 2006.
[RFC4616] Zeilenga, K., "The PLAIN Simple Authentication and Security Layer (SASL) Mechanism", RFC 4616, DOI 10.17487/RFC4616, August 2006.
[RFC4865] White, G. and G. Vaudreuil, "SMTP Submission Service Extension for Future Message Release", RFC 4865, DOI 10.17487/RFC4865, May 2007.
[RFC5198] Klensin, J. and M. Padlipsky, "Unicode Format for Network Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008.
[RFC5248] Hansen, T. and J. Klensin, "A Registry for SMTP Enhanced Mail System Status Codes", BCP 138, RFC 5248, DOI 10.17487/RFC5248, June 2008.
[RFC5256] Crispin, M. and K. Murchison, "Internet Message Access Protocol - SORT and THREAD Extensions", RFC 5256, DOI 10.17487/RFC5256, June 2008.
[RFC5321] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, DOI 10.17487/RFC5321, October 2008.
[RFC5322] Resnick, P., "Internet Message Format", RFC 5322, DOI 10.17487/RFC5322, October 2008.
[RFC5788] Melnikov, A. and D. Cridland, "IMAP4 Keyword Registry", RFC 5788, DOI 10.17487/RFC5788, March 2010.
[RFC6154] Leiba, B. and J. Nicolson, "IMAP LIST Extension for Special-Use Mailboxes", RFC 6154, DOI 10.17487/RFC6154, March 2011.
[RFC6409] Gellens, R. and J. Klensin, "Message Submission for Mail", STD 72, RFC 6409, DOI 10.17487/RFC6409, November 2011.
[RFC6532] Yang, A., Steele, S. and N. Freed, "Internationalized Email Headers", RFC 6532, DOI 10.17487/RFC6532, February 2012.
[RFC6533] Hansen, T., Newman, C. and A. Melnikov, "Internationalized Delivery Status and Disposition Notifications", RFC 6533, DOI 10.17487/RFC6533, February 2012.
[RFC6710] Melnikov, A. and K. Carlberg, "Simple Mail Transfer Protocol Extension for Message Transfer Priorities", RFC 6710, DOI 10.17487/RFC6710, August 2012.
[RFC7159] Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 2014.
[RFC7493] Bray, T., "The I-JSON Message Format", RFC 7493, DOI 10.17487/RFC7493, March 2015.
[RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: Use of Transport Layer Security (TLS) for Email Submission and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018.

Author's Address

Neil Jenkins FastMail Level 2, 114 William St Melbourne, VIC 3000 Australia EMail: neilj@fastmailteam.com URI: https://www.fastmail.com