JMAP                                                          N. Jenkins
Internet-Draft                                                  FastMail
Updates: 5788 (if approved)                                July 16,                             October 30, 2017
Intended status: Standards Track
Expires: January 17, May 3, 2018

                             JMAP for Mail
                        draft-ietf-jmap-mail-01
                        draft-ietf-jmap-mail-02

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 http://datatracker.ietf.org/drafts/current/. 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 January 17, May 3, 2018.

Copyright Notice

   Copyright (c) 2017 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
   (http://trustee.ietf.org/license-info)
   (https://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   3
     1.1.  Notational Conventions  . . . . . . . . . . . . . . . . .   3
     1.2.  Terminology . . . . . . . . . . . . . . . . . . . . . . .   4
     1.3.  Addition to the capabilities object . . . . . . . . . . .   4
   2.  Mailboxes . . . . . . . . . . . . . . . . . . . . . . . . . .   4   5
     2.1.  getMailboxes  . . . . . . . . . . . . . . . . . . . . . .   7   8
     2.2.  getMailboxUpdates . . . . . . . . . . . . . . . . . . . .   8
     2.3.  setMailboxes  . . . . . . . . . . . . . . . . . . . . . .  10
       2.3.1.  Ordering of changes .  getMailboxList  . . . . . . . . . . . . . . . .  11
       2.3.2.  Creating mailboxes  . . . . . . . . . . . . . . . . .  11
       2.3.3.  Updating mailboxes  . . . . . . . . . . . . . . .   8
     2.4.  getMailboxListUpdates . .  12
       2.3.4.  Destroying mailboxes . . . . . . . . . . . . . . . .  13
       2.3.5.  Response   9
     2.5.  setMailboxes  . . . . . . . . . . . . . . . . . . . . . .  13   9
   3.  MessageLists  Threads . . . . . . . . . . . . . . . . . . . . . . . .  15
     3.1.  getMessageList . . .  10
     3.1.  getThreads  . . . . . . . . . . . . . . . . . .  16
       3.1.1.  Filtering . . . . .  10
       3.1.1.  Example . . . . . . . . . . . . . . . . .  17
       3.1.2.  Sorting . . . . . .  11
     3.2.  getThreadUpdates  . . . . . . . . . . . . . . . . .  20
       3.1.3.  Thread collapsing . . .  11
   4.  Messages  . . . . . . . . . . . . . . .  21
       3.1.4.  Windowing . . . . . . . . . . .  11
     4.1.  getMessages . . . . . . . . . . .  22
       3.1.5.  Response . . . . . . . . . . . .  16
       4.1.1.  Example . . . . . . . . . .  22
     3.2.  getMessageListUpdates . . . . . . . . . . . . .  17
     4.2.  getMessageUpdates . . . . .  24
   4.  Threads . . . . . . . . . . . . . . .  17
     4.3.  getMessageList  . . . . . . . . . . . .  27
     4.1.  getThreads . . . . . . . . .  17
       4.3.1.  Filtering . . . . . . . . . . . . . .  27
     4.2.  getThreadUpdates . . . . . . . .  17
       4.3.2.  Sorting . . . . . . . . . . . .  29
   5.  Messages . . . . . . . . . . .  20
       4.3.3.  Thread collapsing . . . . . . . . . . . . . . .  31
     5.1.  getMessages . . .  21
       4.3.4.  Response  . . . . . . . . . . . . . . . . . . . .  36
     5.2.  getMessageUpdates . .  21
     4.4.  getMessageListUpdates . . . . . . . . . . . . . . . . . .  38
     5.3.  22
     4.5.  setMessages . . . . . . . . . . . . . . . . . . . . . . .  40
       5.3.1.  Saving a draft  . . . . . .  22
     4.6.  importMessages  . . . . . . . . . . . . .  41
       5.3.2.  Updating messages . . . . . . . .  23
     4.7.  copyMessages  . . . . . . . . . .  43
       5.3.3.  Sending messages . . . . . . . . . . . .  25
   5.  MessageSubmission . . . . . .  44
       5.3.4.  Cancelling a send . . . . . . . . . . . . . . . .  27
     5.1.  getMessageSubmissions . .  45
       5.3.5.  Destroying messages . . . . . . . . . . . . . . . .  31
     5.2.  getMessageSubmissionUpdates .  45
       5.3.6.  Response . . . . . . . . . . . . . .  31
     5.3.  getMessageSubmissionList  . . . . . . . .  45
     5.4.  importMessages . . . . . . . .  31
     5.4.  getMessageSubmissionListUpdates . . . . . . . . . . . . .  47  32
     5.5.  copyMessages  . . .  setMessageSubmissions . . . . . . . . . . . . . . . . . . .  48  32
   6.  Identities  . . . . . . . . . . . . . . . . . . . . . . . . .  50  34
     6.1.  getIdentities . . . . . . . . . . . . . . . . . . . . . .  50  35
     6.2.  getIdentityUpdates  . . . . . . . . . . . . . . . . . . .  51  35
     6.3.  setIdentities . . . . . . . . . . . . . . . . . . . . . .  53  35
   7.  SearchSnippets  . . . . . . . . . . . . . . . . . . . . . . .  56  36
     7.1.  getSearchSnippets . . . . . . . . . . . . . . . . . . . .  57  36
   8.  Vacation Response . . . . . . . . . . . . . . . . . . . . . .  58  38
     8.1.  getVacationResponse . . . . . . . . . . . . . . . . . . .  59  39
     8.2.  setVacationResponse . . . . . . . . . . . . . . . . . . .  59  39
   9.  Security considerations . . . . . . . . . . . . . . . . . . .  39
   10. References  . . . . . . . . . . . . . . . . . . . . . . . . .  61
     9.1.  39
     10.1.  Normative References . . . . . . . . . . . . . . . . . .  61
     9.2.  39
     10.2.  URIs . . . . . . . . . . . . . . . . . . . . . . . . . .  61  41

   Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .  61  41

1.  Introduction

   JMAP 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 JSON. 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:

   o  "Boolean|String" - The value is either a JSON "Boolean" value, or
      a JSON "String" value.

   o  "Foo" - Any name that is not a native JSON type means an object
      for which the properties (and their types) are defined elsewhere
      within this document.

   o  "Foo[]" - An array of objects of type "Foo".

   o  "String[Foo]" - A JSON "Object" being used as a map (associative
      array), where all the values are of type "Foo".

1.2.  Terminology

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

1.3.  Addition to the capabilities object

   The capabilities object is returned as part

   Object properties may also have a set of attributes defined along
   with the standard JMAP
   authentication response; see type signature.  These have the JMAP spec.  Servers supporting
   _this_ following meanings:

   o  *sever-set*: Only the server can set the value for this property.
      The client MUST NOT send this property when creating a new object
      of this type.

   o  *immutable*: The value MUST NOT change after the object is
      created.

   o  *default*: (This is followed by a JSON value).  The value that
      will be used for this property if it is omitted when creating a
      new object of this type.

1.2.  Terminology

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

1.3.  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 "{TODO: URI for this spec}"
   to the capabilities object.  The value of this property is an object
   which SHOULD contain the following information on server
   capabilities:

   o  *maxMailboxesPerMessage*: "Number|null" The maximum number of
      mailboxes that can be can assigned to a single message.  This MUST
      be an integer >= 1, or "null" for no limit (or rather, the limit
      is always the number of mailboxes in the account).

   o  *maxSizeMessageAttachments*: "Number" The maximum total size of
      attachments, in bytes, allowed for messages.  A server MAY still
      reject messages 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).

   o  *canDelaySend*: "Boolean" Does  *maxDelayedSend*: "Number" The number in seconds of the maximum
      delay the server support inserting a
      message into supports in sending (see the outbox to be sent later at a user-specified time? MessageSubmission
      object).  This is "0" if the server does not support delayed send.

   o  *messageListSortOptions*: "String[]" A list of all the message
      properties the server supports for sorting by.  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.

2.  Mailboxes

   o  *submissionExtensions*: "String[String[]]" A mailbox represents JMAP implementation
      that talks to a named set of emails.  This is the primary
   mechanism for organising messages within Submission [RFC6409] server SHOULD have a
      configuration setting that allows an account.  It is analogous administrator to expose a folder or a label new
      submission EHLO capability in other systems.  A mailbox may perform this field.  This allows a
   certain role JMAP
      server to gain access to a new submission extension without code
      changes.  By default, the JMAP server should show only known safe-
      to-expose EHLO capabilities in this field, and hide EHLO
      capabilites that are only relevant to the system; see below for more details. JMAP server.  Each key
      in the object is the _ehlo-name_, and the value is a list of
      _ehlo-args_.  Examples of safe-to-expose Submission extensions
      include:

      *  FUTURERELEASE ([RFC4865])

      *  SIZE ([RFC1870])

      *  DSN ([RFC3461])

      *  DELIVERYBY ([RFC2852])

      *  MT-PRIORITY ([RFC6710])

      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.  The full
      IANA registry of submission extensions can be found at
      <https://www.iana.org/assignments/mail-parameters/mail-
      parameters.xhtml#mail-parameters-2>

2.  Mailboxes

   A mailbox represents a named set of emails.  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.

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

   A *Mailbox* object has the following properties:

   o  *id*: "String" (immutable; server-set) The id of the mailbox.  This property is immutable.

   o  *name*: "String" User-visible name for the mailbox, e.g.  "Inbox".
      This may be any UTF-8 string ([RFC3629]) of at least 1 character
      in length and maximum 256 bytes in size.  Servers SHOULD forbid
      sibling Mailboxes with the same name.

   o  *parentId*: "String|null" (default: "null") 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.

   o  *role*: "String|null" (default: "null") Identifies system
      mailboxes.  This property can only be set on create.  After the
      record has been created, this property is immutable.  The
      following values MUST be used for the relevant mailboxes:

      *  "inbox" - the mailbox to which new mail is delivered by
         default, unless diverted by a rule or spam filter etc.

      *  "archive" - messages the user does not need right now, but does
         not wish to delete.

      *  "drafts" - messages the user is currently writing and are not
         yet sent.

      *  "outbox" - messages the user has finished writing and wishes to
         send (see the "setMessages" method description for more
         information).  A mailbox with this role MUST be present if the
         user is allowed to send mail through an account.  If not
         present, the user cannot send mail with that account.

      *  "sent" - messages the user has sent.

      *  "trash" - messages the user has deleted.

      *  "spam" - messages considered spam by the server.

      *  "templates" - drafts which should be used as templates (i.e.
         used as the basis for creating new drafts).

      No two mailboxes may have the same role.  Mailboxes without a
      known purpose MUST have a role of "null".  An account is not
      required to have mailboxes with any of the above roles.  A client
      MAY create new mailboxes with a role property to help them keep
      track of a use-case not covered by the above list.  To avoid
      potential conflict with any special behaviour a server might apply
      to mailboxes with certain roles in the future, any roles not in
      the above list created by the client must begin with ""x-"".  The
      client MAY attempt to create mailboxes with the standard roles if
      not already present, but the server MAY reject these.

   o  *sortOrder*: "Number" (default: "0") 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 <=
      sortOrder < 2^31.  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.

   o  *mustBeOnlyMailbox*: "Boolean" If "true", messages in this mailbox
      may not also be in any other mailbox that also has
      "mustBeOnlyMailbox: true".  If "false", messages may be added to
      this mailbox in addition to any other mailbox (i.e. it's a label).
      This property is immutable.

   o  *mayReadItems*: "Boolean" (server-set) If true, may use this
      mailbox as part of a filter in a _getMessageList_ call.  If a
      submailbox is shared but not the parent mailbox, this may be
      "false".

   o  *mayAddItems*: "Boolean" (server-set) The user may add messages to
      this mailbox (by either creating a new message or moving an
      existing one).

   o  *mayRemoveItems*: "Boolean" (server-set) The user may remove
      messages from this mailbox (by either changing the mailboxes of a
      message or deleting it).

   o  *mayCreateChild*: "Boolean" (server-set) The user may create a
      mailbox with this mailbox as its parent.

   o  *mayRename*: "Boolean" (server-set) The user may rename the
      mailbox or make it a child of another mailbox.

   o  *mayDelete*: "Boolean" (server-set) The user may delete the
      mailbox itself.

   o  *totalMessages*: "Number" (server-set) The number of messages in
      this mailbox.

   o  *unreadMessages*: "Number" (server-set) The number of messages in
      this mailbox that have neither the "$Seen" keyword nor the
      "$Draft" keyword.

   o  *totalThreads*: "Number" (server-set) The number of threads where
      at least one message in the thread is in this mailbox.

   o  *unreadThreads*: "Number" (server-set) The number of threads where
      at least one message in the thread has neither the "$Seen" keyword
      nor the "$Draft" keyword AND at least one message in the thread is
      in this mailbox (but see below for special case handling of
      Trash).  Note, the unread message does not need to be the one in
      this mailbox.

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

   1.  Messages that are *only* in the Trash (and no other mailbox) are
       ignored when calculating the "unreadThreads" count of other
       mailboxes.

   2.  Messages that are *not* in the Trash are ignored when calculating
       the "unreadThreads" count for the Trash mailbox.

   The result of this is that messages 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 messages in the Trash
   when viewing a thread in another mailbox and vice versa.  This allows
   you to delete a single message 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 messages: an unread message in the
   Trash and a read message in the Inbox.  The "unreadThreads" count
   would be "1" for the Trash and "0" for the Inbox.

   For IMAP compatibility, a message 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.  getMailboxes

   Mailboxes can either

   Standard _getFoos_ method.  The _ids_ argument may be fetched explicitly by id, or "null" to fetch
   all of them at once.  To fetch mailboxes, make a call to "getMailboxes".  It takes
   the following arguments:

   o  *accountId*: "String|null" The Account

2.2.  getMailboxUpdates

   Standard _getFooUpdates_ method, but with one extra argument to fetch the mailboxes for.
      If "null", the primary account is used.
   _mailboxUpdates_ response:

   o  *ids*:  *changedProperties*: "String[]|null" The ids of the mailboxes to fetch. If
      "null", all mailboxes in only the account are returned.

   o  *properties*: "String[]|null" The properties of each mailbox to
      fetch.  If "null", all properties are returned.  The id of counts
      (unread/total messages/threads) have changed since the
      mailbox old state,
      this will *always* be returned, even if not explicitly
      requested.

   The response to _getMailboxes_ is called _mailboxes_. It has the
   following arguments:

   o  *accountId*: "String" The id list of properties that may have changed, i.e.
      "["totalMessages", "unreadMessages", "totalThreads",
      "unreadThreads"]".  If the account used for server is unable to tell if only counts
      have changed, it MUST just be "null".

   Since counts frequently change but the call.

   o  *state*: "String" A string representing rest of the mailboxes state on
   for most use cases changes rarely, the server
      for *all* mailboxes.  If can help the state client
   optimise data transfer by keeping track of a mailbox changes, or a new
      mailbox is created, or a mailbox is destroyed, this string will
      change.  It is used changes to get delta updates.

   o  *list*: "Mailbox[]" An message counts
   separately to other state changes.  The _changedProperties_ array of the Mailbox objects requested.
      This will may
   be used directly via a result reference in a subsequent getMailboxes
   call in a single request.

2.3.  getMailboxList

   Standard _getFooList_ method.

   The *FilterCondition* object (optionally passed as the *empty array* if the _ids_ argument was _filter_
   argument) has the empty
      array, or contained only ids for mailboxes that could not following properties, any of which may be
      found. omitted:

   o  *notFound*: "String[]|null" This array contains the ids passed to  *parentId*: "String|null" The Mailbox _parentId_ property must
      match the method given value exactly.

   o  *hasRole*: "Boolean" If this is "true", a Mailbox matches if it
      has a non-"null" value for mailboxes that do not exist, or "null" its _role_ property.

   A Mailbox object matches the filter if all
      requested ids were found.  It MUST be "null" and only if all of the _ids_ argument
      in the call was "null". given
   conditions given match.  If zero properties are specified, it is
   automatically "true" for all objects.

   The following errors may properties MUST be returned instead of the _mailboxes_
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds to supported for sorting:

   o  "sortOrder"

   o  "name"

2.4.  getMailboxListUpdates

   Standard _getFooListUpdates_ method.

2.5.  setMailboxes

   Standard _setFoos_ method.  The following extra _SetError_ types are
   defined:

   For *create*:

   o  "maxQuotaReached": The user has reached a valid account, but the account does not support this
   data type.

   "requestTooLarge": Returned if server-defined limit on
      the number of _ids_ requested by mailboxes.

   For *update*:

   o  "forbidden": The update would violate a mayXXX property.

   For *destroy*:

   o  "forbidden": The update would violate a mayXXX property.

   o  "mailboxHasChild": The mailbox still has at least one child
      mailbox.  The client MUST remove these before it can delete the
      parent mailbox.

   o  "mailboxHasMessage": The mailbox has at least one message assigned
      to it.  The client exceeds MUST remove these before it can delete the maximum number
      mailbox.

3.  Threads

   Replies are grouped together with the server original message to form a
   thread.  In JMAP, a thread is willing simply a flat list of messages, ordered
   by date.  Every message MUST belong to process in a single method call.

   "invalidArguments": Returned thread, even if it is the request
   only message in the thread.

   The JMAP spec does not include one of require the required arguments, or one of server to use any particular
   algorithm for determining whether two messages belong to the arguments same
   thread, however there is of a recommended algorithm in the wrong type,
   or otherwise invalid.  A "description" property MAY be present on the
   response object to help debug with an explanation
   implementation guide [1].

   If messages are delivered out of what order for some reason, a user may
   receive two messages in the problem
   was.

2.2.  getMailboxUpdates same thread but without headers that
   associate them with each other.  The _getMailboxUpdates_ call allows arrival of a client third message in
   the thread may provide the missing references to efficiently update join them all
   together into a single thread.  Since the state "threadId" of its cached mailboxes a message is
   immutable, if the server wishes to match merge the threads, it MUST handle
   this by deleting and reinserting (with a new state on message id) the
   server.  It takes messages
   that change threadId.

   A *Thread* object has the following arguments: properties:

   o  *accountId*: "String|null"  *id*: "String" (immutable) The id of the account to use for this
      call.  If "null", the primary account will be used. thread.

   o  *sinceState*: "String"  *messageIds*: "String[]" The current state ids of the client.  This is messages in the string thread,
      sorted such that:

      *  Any message with the "$Draft" keyword that was returned as has an "In-Reply-To"
         header is sorted after the _state_ argument _first_ non-draft message in the
      _mailboxes_ response.  The server will return the changes made
      since this state.

   o  *fetchRecords*: "Boolean|null" If "true", immediately after
      outputting a _mailboxUpdates_ response, an implicit call will be
      made to _getMailboxes_
         thread with the _changed_ property of corresponding "Message-Id" header, but before
         any subsequent non-draft messages.

      *  Other than that, everything is sorted in _date_ order (as
         determined by the response
      as date property on the _ids_ argument, and _Message_ object),
         oldest first.

      *  If two messages are identical under the _fetchRecordProperties_ argument as above two conditions,
         the _properties_ argument.  If "false" or "null", no implicit call
      will sort is server-dependent but MUST be made.

   o  *fetchRecordProperties*: "String[]|null" If "null", all Mailbox
      properties will be fetched unless _onlyCountsChanged_ in the
      _mailboxUpdates_ response stable (sorting by id
         is "true", in which case only the 4
      counts properties will be returned (_totalMessages_,
      _unreadMessages_, _totalThreads_ and _unreadThreads_).  If not
      "null", this value will be passed through to the _getMailboxes_
      call regardless of the _onlyCountsChanged_ value in the
      _mailboxUpdates_ response. recommended).

   The response to _getMailboxUpdates_ following JMAP methods are supported:

3.1.  getThreads

   Standard _getFoos_ method.

3.1.1.  Example

   Request:

                      [ "getThreads", {
                        "ids": ["f123u4", "f41u44"],
                      }, "#1" ]

   with response:

                [ "threads", {
                  "accountId": "acme",
                  "state": "f6a7e214",
                  "list": [
                    {
                      "id": "f123u4",
                      "messageIds": [ "eaa623", "f782cbb"]
                    },
                    {
                      "id": "f41u44",
                      "messageIds": [ "82cf7bb" ]
                    }
                  ],
                  "notFound": null
                }, "#1" ]

3.2.  getThreadUpdates

   Standard _getFooUpdates_ method.

4.  Messages

   A *Message* object is called _mailboxUpdates_. a JSON representation of an [RFC5322] message
   that hides the complexities of MIME.  All special encodings of either
   headers or textual body parts, such as Base64 ([RFC4648]), or
   [RFC2047] encoding of non-ASCII characters, MUST be fully decoded
   into UTF-8.  It has the following arguments: properties:

   o  *accountId*:  *id*: "String" (immutable; server-set) The id of the account used for the call.

   o  *oldState*: "String" message.
      This is the _sinceState_ argument echoed
      back; the state from which JMAP id, NOT the server is returning changes. [RFC5322] Message-Id header.

   o  *newState*:  *blobId*: "String" This is the state (immutable; server-set) The id representing the client will
      raw [RFC5322] message.  This may be in after
      applying the set of changes used to download the old state. original
      message or to attach it directly to another message etc.

   o  *changed*: "String[]" An array of Mailbox ids where a property  *threadId*: "String" (immutable; server-set) The id of the mailbox has changed between the old state and the new state,
      or the mailbox has been created, and the mailbox has not been
      destroyed. thread
      to which this message belongs.

   o  *removed*: "String[]" An array  *mailboxIds*: "String[Boolean]" The set of Mailbox mailbox ids for mailboxes which
      have been destroyed since the old state.

   o  *onlyCountsChanged*: "Boolean" Indicates that only the mailbox
      counts (unread/total messages/threads) have changed since the old
      state.  The client can then use this to optimise its data transfer
      and only fetch the counts.  If the server
      message is unable in.  A message MUST belong to tell if
      only counts have changed, it should just always return "false".

   If a mailbox has been modified AND deleted since the oldState, the
   server should just return the id in the _removed_ array, but MAY
   return one or more mailboxes at
      all times (until it in the _changed_ array is deleted).  The set is represented as well.  If an
      object, with each key being a mailbox has been
   created AND deleted since the oldState, the server SHOULD remove the
   mailbox id from the response entirely, but MAY include it _Mailbox id_. The value for each key
      in the
   _removed_ array.

   The following errors may object MUST be returned instead "true".

   o  *keywords*: "String[Boolean]" (default: "{}") A set of keywords
      that apply to the "mailboxUpdates"
   response:

   "accountNotFound": Returned if message.  The set is represented as an _accountId_ was explicitly included object,
      with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds to a valid account, but the account does not support this
   data type.

   "invalidArguments": Returned if the request does not include one of
   the required arguments, or one of the arguments is of keys being the wrong type,
   or otherwise invalid.  A "description" property MAY be present on _keywords_. The value for each key in the
   response
      object to help debug MUST be "true".  Keywords are shared with an explanation of what the problem
   was.

   "cannotCalculateChanges": Returned if the server cannot calculate the
   changes from the state string given by the client.  Usually due to
   the client's state being too old.  The client MUST invalidate its
   Mailbox cache.

2.3.  setMailboxes

   Mailboxes can be created, updated and destroyed using the
   _setMailboxes_ method.  The method takes the following arguments:

   o  *accountId*: "String|null" The id of the account to use for this
      call.  If "null", defaults to the primary account.

   o  *ifInState*: "String|null" This is a state string as returned by
      the _getMailboxes_ method.  If supplied, the string must match the
      current state, otherwise the method will be aborted and a
      "stateMismatch" error returned.  If "null", any changes will be
      applied to the current state.

   o  *create*: "String[Mailbox]|null" A map of _creation id_ (an
      arbitrary string set by the client) to Mailbox objects.  If
      "null", no objects will be created.

   o  *update*: "String[Mailbox]|null" A map of mailbox id to objects
      containing the properties to update for that Mailbox.  If "null",
      no objects will be updated.

   o  *destroy*: "String[]|null" A list of ids for Mailboxes to
      permanently delete.  If "null", no objects will be deleted.

   If a create, update or destroy is rejected, the appropriate error
   MUST be added to the notCreated/notUpdated/notDestroyed property of
   the response and the server MUST continue to the next create/update/
   destroy.  It does not terminate the method.

2.3.1.  Ordering of changes

   Each create, update or destroy is considered an atomic unit. IMAP.  The
   server MAY commit some of the changes but not others, however MUST
   NOT only commit part of an update to a single record (e.g. update the
   _name_ field but not the _parentId_ field, if both six
      system keywords from IMAP are supplied in
   the update object). treated specially.  The final state MUST be valid after the setMailboxes is finished,
   however the server MAY following
      four keywords have to transition through invalid
   intermediate states (not exposed to the client) while processing the
   individual create/update/destroy requests.  For example, a single
   method call could rename Mailbox A => B, and simultaneously rename
   Mailbox B => A.  The final state is valid, so this is allowed,
   however if processed sequentially there will be an internal state
   where temporarily both mailboxes have the same name.

   A Mailbox may reference another Mailbox object as a parent.  When a
   Mailbox is created or modified, it may reference another Mailbox
   being created _in the same API request_ by using the creation id
   prefixed with a "#".  The order of the method calls in the request by
   the client MUST be such that the mailbox being referenced is created
   in *either the same or an earlier method call*. If within the same
   method call, the server MUST process the parent create first, as if
   this fails the create/update that references it will also fail.

   Creation ids sent by the client SHOULD be unique within the single
   API request for a particular data type.  If a creation id is reused,
   the server MUST map the creation id to the most recently created item
   with that id.

2.3.2.  Creating mailboxes

   The properties of the Mailbox object submitted for creation MUST
   conform to the following conditions:

   o  The _id_ property MUST NOT be present.

   o  The _parentId_ property MUST be either "null" or be a valid id for
      a mailbox for which the "mayCreateChild" property is "true".

   o  The _role_ property MUST be either "null", a valid role as listed
      in the Mailbox object specification, or prefixed by ""x-"".

   o  The _mustBeOnlyMailbox_ property MUST NOT be present.  This is
      server dependent and will be set by the server.

   o  The _mayXXX_ properties MUST NOT be present.  Restrictions may
      only be set by the server for system mailboxes, or when sharing
      mailboxes with other users (setting sharing is not defined yet in
      this spec).

   o  The _totalMessages_, _unreadMessages_, _totalThreads_ and
      _unreadThreads_ properties MUST NOT be present.

   If any of the properties are invalid, the server MUST reject the
   create with an "invalidProperties" error.  The Error object SHOULD
   contain a property called _properties_ of type "String[]" that lists
   *all* the properties that were invalid.  The object MAY also contain
   a _description_ property of type "String" with a user-friendly
   description of the problems.

   There may be a maximum number of mailboxes allowed on the server.  If
   this is reached, any attempt at creation will be rejected with a
   "maxQuotaReached" error.

2.3.3.  Updating mailboxes

   If the _id_ given does not correspond to a Mailbox in the given
   account, the update MUST be rejected with a "notFound" error.

   All properties being updated must be of the correct type, not
   immutable or server-set-only, and the new value must obey all
   conditions of the property.  In particular, note the following
   conditions:

   o  The _name_ property MUST be a valid UTF-8 string of at least 1
      character in length and maximum 256 bytes in size.

   o  The _parentId_ property MUST be either "null" or be a valid id for
      _another_ mailbox that is *not a descendant* of this mailbox, and
      for which the "mayCreateChild" property is "true".

   o  These properties are immutable or may only be set by the server:

      *  id

      *  role

      *  mustBeOnlyMailbox

      *  mayReadItems
      *  mayAddItems

      *  mayRemoveItems

      *  mayCreateChild

      *  mayRename

      *  mayDelete

      *  totalMessages

      *  unreadMessages

      *  totalThreads

      *  unreadThreads

   If any of the properties are invalid, the server MUST reject the
   update with an "invalidProperties" error.  The Error object SHOULD
   contain a property called _properties_ of type "String[]" that lists
   *all* the properties that were invalid.  The object MAY also contain
   a _description_ property of type "String" with a user-friendly
   description of the problems.

2.3.4.  Destroying mailboxes

   If the _id_ given does not correspond to a Mailbox in the given
   account, the destruction MUST be rejected with a "notFound" error.

   If the mailbox has "mayDeleteMailbox == false", the destruction MUST
   be rejected with a "forbidden" error.

   A mailbox MUST NOT be destroyed if it still has any child mailboxes.
   Attempts to do so MUST be rejected with a "mailboxHasChild" error.

   A mailbox MUST NOT be destroyed if it has any messages assigned to
   it.  Attempts to do so MUST be rejected with a "mailboxHasMessage"
   error.

2.3.5.  Response

   The response to _setMailboxes_ is called _mailboxesSet_. It has the
   following arguments:

   o  *accountId*: "String" The id of the account used for the call.

   o  *oldState*: "String|null" The state string that would have been
      returned by "getMailboxes" before making the requested changes, or
      "null" if the server doesn't know what the previous state string
      was.

   o  *newState*: "String" The state string that will now be returned by
      "getMailboxes".

   o  *created*: "String[Mailbox]" A map of the creation id to an object
      containing all server-set properties for each successfully created
      Mailbox: _id_, _mustBeOnlyMailbox_, all _mayXXX_ properties,
      _totalMessages_, _unreadMessages_, _totalThreads_ and
      _unreadThreads_.

   o  *updated*: "String[Mailbox|null]" The _keys_ in this map are the
      ids of all mailboxes that were successfully updated.  If the
      server made any other changes to the record beyond those
      explicitly requested by the client, the _value_ for the
      corresponding id in the map is an object containing the updated
      value of each property the *server changed*. Otherwise (if no
      properties changed on the server other than those explicitly
      updated by the client), the value is "null".

   o  *destroyed*: "String[]" A list of ids for Mailboxes that were
      successfully destroyed.

   o  *notCreated*: "String[SetError]" A map of creation id to a
      SetError object for each Mailbox that failed to be created.  The
      possible errors are defined above.

   o  *notUpdated*: "String[SetError]" A map of Mailbox id to a SetError
      object for each Mailbox that failed to be updated.  The possible
      errors are defined above.

   o  *notDestroyed*: "String[SetError]" A map of Mailbox id to a
      SetError object for each Mailbox that failed to be destroyed.  The
      possible errors are defined above.

   The following errors may be returned instead of the _mailboxesSet_
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds to a valid account, but the account does not support this
   data type.

   "accountReadOnly": Returned if the account has "isReadOnly == true".

   "requestTooLarge": Returned if the total number of objects to create,
   update or destroy exceeds the maximum number the server is willing to
   process in a single method call.

   "invalidArguments": Returned if one of the arguments is of the wrong
   type, or otherwise invalid.  A _description_ property MAY be present
   on the response object to help debug with an explanation of what the
   problem was.

   "stateMismatch": Returned if an "ifInState" argument was supplied and
   it does not match the current state.

   Example request:

                       [ "setMailboxes", {
                         "ifInState": "ms4123",
                         "update": {
                           "f3": {
                             "name": "The new name"
                           }
                         },
                         "destroy": [ "f5" ]
                       }, "#0" ]

3.  MessageLists

   A *MessageList* is a sorted query on the set of messages in a user's
   account.  Since it can be very long, the client must specify what
   section of the list to return.  The client can optionally also fetch
   the threads and/or messages for this part of the list.

   The same message may appear in multiple messages lists.  For example,
   it may belong to multiple mailboxes, and of course it can appear in
   searches.  Since messages have an immutable id, a client can easily
   tell if it already has a message cached and only fetch the ones it
   needs.

   When the state changes on the server, a delta update can be requested
   to efficiently update the client's cache of this list to the new
   state.  If the server doesn't support this, the client still only
   needs to fetch the message list again, not the messages themselves.

3.1.  getMessageList

   To fetch a message list, make a call to _getMessageList_. It takes
   the following arguments:

   o  *accountId*: "String|null" The id of the account to use for this
      call.  If "null", the primary account will be used.

   o  *filter*: "FilterCondition|FilterOperator|null" Determines the set
      of messages returned in the results.  See the "Filtering" section
      below for allowed values and semantics.

   o  *sort*: "String[]|null" A list of Message property names to sort
      by.  See the "Sorting" section below for allowed values and
      semantics.

   o  *collapseThreads*: "Boolean|null" If true, each thread will only
      be returned once in the resulting list, at the position of the
      first message in the list (given the filter and sort order)
      belonging to the thread.  If "false" or "null", threads may be
      returned multiple times.

   o  *position*: "Number|null" The 0-based index of the first result in
      the list to return.  If a negative value is given, the call MUST
      be rejected with an "invalidArguments" error.  If "null", 0 is
      used.

   o  *anchor*: "String|null" A Message id.  The index of this message
      id will be used in combination with the "anchorOffset" argument to
      determine the index of the first result to return (see the
      "Windowing" section below for more details).

   o  *anchorOffset*: "Number|null" The index of the anchor message
      relative to the index of the first result to return.  This MAY be
      negative.  For example, "-1" means the first message after the
      anchor message should be the first result in the results returned
      (see the "Windowing" section below for more details).

   o  *limit*: "Number|null" The maximum number of results to return.
      If "null", no limit is presumed.  The server MAY choose to enforce
      a maximum "limit" argument.  In this case, if a greater value is
      given, the limit should be clamped to the maximum; since the total
      number of results in the list is returned, the client should not
      be relying on how many results are returned to determine if it has
      reached the end of the list.  If a negative value is given, the
      call MUST be rejected with an "invalidArguments" error.

   o  *fetchThreads*: "Boolean|null" If "true", after outputting a
      _messageList_ response, an implicit call will be made to
      _getThreads_ with the _threadIds_ array in the response as the
      _ids_ argument, and the _fetchMessages_ and
      _fetchMessageProperties_ arguments passed straight through from
      the call to _getMessageList_. If "false" or "null", no implicit
      call will be made.

   o  *fetchMessages*: "Boolean|null" If "true" and "fetchThreads ==
      false", then after outputting a _messageList_ response, an
      implicit call will be made to _getMessages_ with the "messageIds"
      array in the response as the _ids_ argument, and the
      _fetchMessageProperties_ argument as the _properties_ argument.
      If "false" or "null", no implicit call will be made.

   o  *fetchMessageProperties*: "String[]|null" The list of properties
      to fetch on any fetched messages.  See _getMessages_ for a full
      description.

   o  *fetchSearchSnippets*: "Boolean|null" If "true", then after
      outputting a _messageList_ and making any other implicit calls, an
      implicit call will be made to _getSearchSnippets_. The
      _messageIds_ array from the response will be used as the
      _messageIds_ argument, and the _filter_ argument will be passed
      straight through.  If "false" or "null", no implicit call will be
      made.

3.1.1.  Filtering

   A *FilterOperator* object has the following properties:

   o  *operator*: "String" This MUST be one of the following strings:
      "AND"/"OR"/"NOT":

      *  *AND*: all of the conditions must match for the filter to
         match.

      *  *OR*: at least one of the conditions must match for the filter
         to match.

      *  *NOT*: none of the conditions must match for the filter to
         match.

   o  *conditions*: "(FilterCondition|FilterOperator)[]" The conditions
      to evaluate against each message.

   A *FilterCondition* object has the following properties:

   o  *inMailbox*: "String|null" A mailbox id.  A message must be in
      this mailbox to match the condition.

   o  *inMailboxOtherThan*: "String|null" A mailbox id.  A message be in
      any mailbox other than this one to match the condition.  This is
      to allow messages solely in trash/spam to be easily excluded from
      a search.

   o  *before*: "Date|null" The date of the message (as returned on the
      Message object) must be before this date to match the condition.

   o  *after*: "Date|null" The date of the message (as returned on the
      Message object) must be on or after this date to match the
      condition.

   o  *minSize*: "Number|null" The size of the message in bytes (as
      returned on the Message object) must be equal to or greater than
      this number to match the condition.

   o  *maxSize*: "Number|null" The size of the message in bytes (as
      returned on the Message object) must be less than this number to
      match the condition.

   o  *allInThreadHaveKeyword*: "String" All messages (including this
      one) in the same thread as this message must have the given
      keyword to match the condition.

   o  *someInThreadHaveKeyword*: "String" At least one message (possibly
      this one) in the same thread as this message must have the given
      keyword to match the condition.

   o  *noneInThreadHaveKeyword*: "String" All messages (including this
      one) in the same thread as this message must *not* have the given
      keyword to match the condition.

   o  *hasKeyword*: "String" This message must have the given keyword to
      match the condition.

   o  *notKeyword*: "String" This message must not have the given
      keyword to match the condition.

   o  *hasAttachment*: "Boolean|null" The "hasAttachment" property of
      the message must be identical to the value given to match the
      condition.

   o  *text*: "String|null" Looks for the text in the _from_, _to_,
      _cc_, _bcc_, _subject_, _textBody_ or _htmlBody_ properties of the
      message.

   o  *from*: "String|null" Looks for the text in the _from_ property of
      the message.

   o  *to*: "String|null" Looks for the text in the _to_ property of the
      message.

   o  *cc*: "String|null" Looks for the text in the _cc_ property of the
      message.

   o  *bcc*: "String|null" Looks for the text in the _bcc_ property of
      the message.

   o  *subject*: "String|null" Looks for the text in the _subject_
      property of the message.

   o  *body*: "String|null" Looks for the text in the _textBody_ or
      _htmlBody_ property of the message.

   o  *header*: "String[]|null" The array MUST contain either one or two
      elements.  The first element is the name of the header to match
      against.  The second (optional) element is the text to look for in
      the header.  If not supplied, the message matches simply if it
      _has_ a header of the given name.

   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:

   o  Text SHOULD be matched in a case-insensitive manner.

   o  Text contained in either (but matched) single or double quotes
      SHOULD be treated as a *phrase search*, that is a match is
      required for that exact word or sequence of words, excluding the
      surrounding quotation marks.  Use "\"", "\'" and "\\" to match a
      literal """, "'" and "\" respectively in a phrase.

   o  Outside of a phrase, white-space SHOULD be treated as dividing
      separate tokens that may be searched for separately in the
      message, but MUST all be present for the message to match the
      filter.

   o  Tokens MAY be matched on a whole-word basis using stemming (so for
      example a text search for "bus" would match "buses" but not
      "business").

   o  When searching inside the _htmlBody_ property, HTML tags and
      attributes SHOULD be ignored.

3.1.2.  Sorting

   The "sort" argument lists the properties to compare between two
   messages to determine which comes first in the sort.  If two messages
   have an identical value for the first property, the next property
   will be considered and so on.  If all properties are the same (this
   includes the case where an empty array or "null" is given as the
   argument), the sort order is server-dependent, but MUST be stable
   between calls to "getMessageList".

   Following the property name there MUST be a space and then either the
   string "asc" or "desc" to specify ascending or descending sort for
   that property.

   The following properties MUST be supported for sorting:

   o  *id* - The id as returned in the Message object.

   o  *date* - The date as returned in the Message object.

   The following properties SHOULD be supported for sorting:

   o  *size* - The size as returned in the Message object.

   o  *from* - This is taken to be either the "name" part of the Emailer
      object, or if none then the "email" part of the Emailer object
      (see the definition of the from property in the Message object).
      If still none, consider the value to be the empty string.

   o  *to* - This is taken to be either the "name" part of the *first*
      Emailer object, or if none then the "email" part of the *first*
      Emailer object (see the definition of the to property in the
      Message object).  If still none, consider the value to be the
      empty string.

   o  *subject* - This is taken to be the subject of the Message with
      any ignoring any leading "Fwd:"s or "Re:"s (case-insensitive
      match).

   o  *keyword:*"$keyword" - This value MUST be considered "true" if the
      message has the keyword, or "false" otherwise.

   o  *allThreadKeyword:*"$keyword" - This value MUST be considered
      "true" for the message if *all* of the messages in the same thread
      (regardless of mailbox) have the keyword.

   o  *someThreadKeyword:*"$keyword" - This value MUST be considered
      "true" for the message if *any* of the messages in the same thread
      (regardless of mailbox) have the keyword.

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

   The method of comparison depends on the type of the property:

   o  "String": Comparison function is server-dependent.  It SHOULD be
      case-insensitive and SHOULD take into account locale-specific
      conventions if known for the user.  However, the server MAY choose
      to just sort based on unicode code point, after best-effort
      translation to lower-case.

   o  "Date": If sorting in ascending order, the earlier date MUST come
      first.

   o  "Boolean": If sorting in ascending order, a "false" value MUST
      come before a "true" value.

   Example sort:

            `[ "someThreadKeyword:$Flagged desc", "date desc" ]

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

3.1.3.  Thread collapsing

   When "collapseThreads == true", then after filtering and sorting the
   message list, the list is further winnowed by removing any messages
   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
   message in the list that belongs to the thread.

3.1.4.  Windowing

   If a _position_ offset is supplied, then this is the 0-based index of
   the first result to return in the list of messages after filtering,
   sorting and collapsing threads.  If the index is greater than or
   equal to the total number of messages in the list, then there are no
   results to return, but this DOES NOT generate an error.  If
   _position_ is "null" (or, equivalently, omitted) this MUST be
   interpreted as "position: 0".

   Alternatively, a message id, called the *anchor* may be given.  In
   this case, after filtering, sorting and collapsing threads, the
   anchor is searched for in the message list.  If found, the *anchor
   offset* is then subtracted from this index.  If the resulting index
   is now negative, it is clamped to 0.  This index is now used exactly
   as though it were supplied as the "position" argument.  If the anchor
   is not found, the call is rejected with an "anchorNotFound" error.

   If an _anchor_ is specified, any position argument supplied by the
   client MUST be ignored.  If _anchorOffset_ is "null", it defaults to
   "0".  If no _anchor_ is supplied, any anchor offset argument MUST be
   ignored.

3.1.5.  Response

   The response to a call to _getMessageList_ is called _messageList_.
   It has the following arguments:

   o  *accountId*: "String" The id of the account used for the call.

   o  *filter*: "FilterCondition|FilterOperator|null" The filter of the
      message list.  Echoed back from the call.

   o  *sort*: "String[]|null" A list of Message property names used to
      sort by.  Echoed back from the call.

   o  *collapseThreads*: "Boolean|null" Echoed back from the call.

   o  *state*: "String" A string encoding the current state on the
      server.  This string will change if the results of the message
      list MAY have changed (for example, there has been a change to the
      state of the set of Messages; it does not guarantee that anything
      in the list has changed).  It may be passed to
      _getMessageListUpdates_ to efficiently get the set of changes from
      the previous state.  Should a client receive back a response with
      a different state string to a previous call, it MUST either throw
      away the currently cached list and fetch it again (note, this does
      not require fetching the messages again, just the list of ids) or,
      if the server supports it, call _getMessageListUpdates_ to get the
      delta difference.

   o  *canCalculateUpdates*: "Boolean" This is "true" if the server
      supports calling "getMessageListUpdates" with these
      "filter"/"sort"/"collapseThreads" parameters.  Note, this does not
      guarantee that the getMessageListUpdates call will succeed, as it
      may only be possible for a limited time afterwards due to server
      internal implementation details.

   o  *position*: "Number" The 0-based index of the first result in the
      "threadIds" array within the complete list.

   o  *total*: "Number" The total number of messages in the message list
      (given the _filter_ and _collapseThreads_ arguments).

   o  *threadIds*: "String[]" The list of Thread ids for each message in
      the list after filtering, sorting and collapsing threads, starting
      at the index given by the _position_ argument of this response,
      and continuing until it hits the end of the list or reaches the
      "limit" number of ids.

   o  *messageIds*: "String[]" The list of Message ids for each message
      in the list after filtering, sorting and collapsing threads,
      starting at the index given by the _position_ argument of this
      response, and continuing until it hits the end of the list or
      reaches the "limit" number of ids.

   The following errors may be returned instead of the "messageList"
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds to a valid account, but the account does not support this
   data type.

   "unsupportedSort": Returned if the _sort_ includes a property the
   server does not support sorting on.

   "cannotDoFilter": Returned if the server is unable to process the
   given _filter_ for any reason.

   "invalidArguments": Returned if the request does not include one of
   the required arguments, or one of the arguments is of the wrong type,
   or otherwise invalid.  A "description" property MAY be present on the
   response object to help debug with an explanation of what the problem
   was.

   "anchorNotFound": Returned if an anchor argument was supplied, but it
   cannot be found in the message list.

3.2.  getMessageListUpdates

   The "getMessageListUpdates" call allows a client to efficiently
   update the state of any cached message list to match the new state on
   the server.  It takes the following arguments:

   o  *accountId*: "String|null" The id of the account to use for this
      call.  If "null", the primary account will be used.

   o  *filter*: "FilterCondition|FilterOperator|null" The filter
      argument that was used with _getMessageList_.

   o  *sort*: "String[]|null" The sort argument that was used with
      _getMessageList_.

   o  *collapseThreads*: "Boolean|null" The _collapseThreads_ argument
      that was used with _getMessageList_.

   o  *sinceState*: "String" The current state of the client.  This is
      the string that was returned as the _state_ argument in the
      _messageList_ response.  The server will return the changes made
      since this state.

   o  *uptoMessageId*: "String|null" The message id of the last message
      in the list that the client knows about.  In the common case of
      the client only having the first X ids cached, this allows the
      server to ignore changes further down the list the client doesn't
      care about.

   o  *maxChanges*: "Number|null" The maximum number of changes to
      return in the response.  See below for a more detailed
      description.

   The response to _getMessageListUpdates_ is called
   _messageListUpdates_ It has the following arguments:

   o  *accountId*: "String" The id of the account used for the call.

   o  *filter*: "FilterCondition|FilterOperator|null" The filter of the
      message list.  Echoed back from the call.

   o  *sort*: "String[]|null" A list of Message property names used to
      sort by.  Echoed back from the call.

   o  *collapseThreads*: "Boolean|null" Echoed back from the call.

   o  *oldState*: "String" This is the "sinceState" argument echoed
      back; the state from which the server is returning changes.

   o  *newState*: "String" This is the state the client will be in after
      applying the set of changes to the old state.

   o  *uptoMessageId*: "String|null" Echoed back from the call.

   o  *total*: "Number" The total number of messages in the message list
      (given the filter and collapseThreads arguments).

   o  *removed*: "RemovedItem[]" The _messageId_ and _threadId_ for
      every message that was in the list in the old state and is not in
      the list in the new state.  If the server cannot calculate this
      exactly, the server MAY return extra messages in addition that MAY
      have been in the old list but are not in the new list.  If an
      _uptoMessageId_ was given AND this id was found in the list, only
      messages positioned before this message that were removed need be
      returned.  In addition, if the sort includes a keyword, the server
      MUST include all messages in the current list for which this
      keyword MAY have changed.  If the sort includes a "some/all-in-
      thread-keyword", then the server MUST include all messages in the
      current list for which this keyword MAY have changed *on any of
      the messages in the thread*.

   o  *added*: "AddedItem[]" The messageId and threadId and index in the
      list (in the new state) for every message that has been added to
      the list since the old state AND every message in the current list
      that was included in the _removed_ array (due to a filter or sort
      based upon a mutable property).  The array MUST be sorted in order
      of index, lowest index first.  If an _uptoMessageId_ was given AND
      this id was found in the list, only messages positioned before
      this message that have been added need be returned.

   A *RemovedItem* object has the following properties:

   o  *messageId*: "String"

   o  *threadId*: "String"

   An *AddedItem* object has the following properties:

   o  *messageId*: "String"
   o  *threadId*: "String"

   o  *index*: "Number"

   The result of this should be that if the client has a cached sparse
   array of message ids in the list in the old state:

messageIds = [ "id1", "id2", null, null, "id3", "id4", null, null, null ]

   then if it *splices out* all messages in the removed array:

    removed = [{ messageId: "id2", ... }];
    messageIds => [ "id1", null, null, "id3", "id4", null, null, null ]

   and *splices in* (in order) all of the messages in the added array:

added = [{ messageId: "id5", index: 0, ... }];
messageIds => [ "id5", "id1", null, null, "id3", "id4", null, null, null ]

   then the message list will now be in the new state.

   The following errors may be returned instead of the
   "messageListUpdates" response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds to a valid account, but the account does not support this
   data type.

   "invalidArguments": Returned if the request does not include one of
   the required arguments, or one of the arguments is of the wrong type,
   or otherwise invalid.  A _description_ property MAY be present on the
   response object to help debug with an explanation of what the problem
   was.

   "tooManyChanges": Returned if there are more changes the the client's
   _maxChanges_ argument.  Each item in the removed or added array is
   considered as one change.  The client may retry with a higher max
   changes or invalidate its cache of the message list.

   "cannotCalculateChanges": Returned if the server cannot calculate the
   changes from the state string given by the client.  Usually due to
   the client's state being too old.  The client MUST invalidate its
   cache of the message list.

4.  Threads

   Replies are grouped together with the original message to form a
   thread.  In JMAP, a thread is simply a flat list of messages, ordered
   by date.  Every message MUST belong to a thread, even if it is the
   only message in the thread.

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

   If messages are delivered out of order for some reason, a user may
   receive two messages in the same thread but without headers that
   associate them with each other.  The arrival of a third message in
   the thread may provide the missing references to join them all
   together into a single thread.  Since the "threadId" of a message is
   immutable, if the server wishes to merge the threads, it MUST handle
   this by deleting and reinserting (with a new message id) the messages
   that change threadId.

   A *Thread* object has the following properties:

   o  *id*: "String" The id of the thread.  This property is immutable.

   o  *messageIds*: "String[]" The ids of the messages in the thread,
      sorted such that:

      *  Any message with the "$Draft" keyword that has an "In-Reply-To"
         header is sorted after the _first_ non-draft message in the
         thread with the corresponding "Message-Id" header, but before
         any subsequent non-draft messages.

      *  Other than that, everything is sorted in _date_ order (as
         determined by the date property on the _Message_ object),
         oldest first.

      *  If two messages are identical under the above two conditions,
         the sort is server-dependent but MUST be stable (sorting by id
         is recommended).

4.1.  getThreads

   Threads can only be fetched explicitly by id.  To fetch threads, make
   a call to _getThreads_. It takes the following arguments:

   o  *accountId*: "String|null" The id of the account to use for this
      call.  If not given, defaults to the primary account.

   o  *ids*: "String[]" An array of ids for the threads to fetch.

   o  *fetchMessages*: "Boolean|null" If true, after outputting a
      _threads_ response, an implicit call will be made to _getMessages_
      with a list of all message ids in the returned threads as the
      _ids_ argument, and the _fetchMessageProperties_ argument as the
      _properties_ argument.  If "false" or "null", no implicit call
      will be made.

   o  *fetchMessageProperties*: "String[]|null" The list of properties
      to fetch on any fetched messages.  See _getMessages_ for a full
      description.

   The response to _getThreads_ is called _threads_. It has the
   following arguments:

   o  *accountId*: "String" The id of the account used for the call.

   o  *state*: "String" A string encoding the current state on the
      server.  This string will change if any threads change (that is,
      new messages arrive, or messages are deleted, as these are the
      only two events that change thread membership).  It can be passed
      to _getThreadUpdates_ to efficiently get the list of changes from
      the previous state.

   o  *list*: "Thread[]" An array of Thread objects for the requested
      thread ids.  This may not be in the same order as the ids were in
      the request.

   o  *notFound*: "String[]|null" An array of thread ids requested which
      could not be found, or "null" if all ids were found.

   The following errors may be returned instead of the "threads"
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds to a valid account, but the account does not support this
   data type.

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

   "invalidArguments": Returned if the request does not include one of
   the required arguments, or one of the arguments is of the wrong type,
   or otherwise invalid.  A _description_ property MAY be present on the
   response object to help debug with an explanation of what the problem
   was.

   Example of a successful request:

                     [ "getThreads", {
                       "ids": ["f123u4", "f41u44"],
                       "fetchMessages": false,
                       "fetchMessageProperties": null
                     }, "#1" ]

   and response:

                [ "threads", {
                  "state": "f6a7e214",
                  "list": [
                    {
                      "id": "f123u4",
                      "messageIds": [ "eaa623", "f782cbb"]
                    },
                    {
                      "id": "f41u44",
                      "messageIds": [ "82cf7bb" ]
                    }
                  ],
                  "notFound": null
                }, "#1" ]

4.2.  getThreadUpdates

   When messages are created or deleted, new threads may be created, or
   the set of messages belonging to an existing thread may change.  If a
   call to _getThreads_ returns with a different _state_ string in the
   response to a previous call, the state of the threads has changed on
   the server and the client needs to work out which part of its cache
   is now invalid.

   The _getThreadUpdates_ call allows a client to efficiently update the
   state of any cached threads to match the new state on the server.  It
   takes the following arguments:

   o  *accountId*: "String|null" The id of the account to use for this
      call.  If not given, defaults to the primary account.

   o  *sinceState*: "String" The current state of the client.  This is
      the string that was returned as the _state_ argument in the
      _threads_ response.  The server will return the changes made since
      this state.

   o  *maxChanges*: "Number|null" The maximum number of Thread ids to
      return in the response.  The server MAY choose to clamp this value
      to a particular maximum or set a maximum if none is given by the
      client.  If supplied by the client, the value MUST be a positive
      integer greater than 0.  If a value outside of this range is
      given, the server MUST reject the call with an "invalidArguments"
      error.

   o  *fetchRecords*: "Boolean|null" If "true", immediately after
      outputting a _threadUpdates_ response, an implicit call will be
      made to _getThreads_ with the _changed_ property of the response
      as the _ids_ argument, and _fetchMessages_ equal to "false".

   The response to _getThreadUpdates_ is called _threadUpdates_. It has
   the following arguments:

   o  *accountId*: "String" The id of the account used for the call.

   o  *oldState*: "String" This is the _sinceState_ argument echoed
      back; the state from which the server is returning changes.

   o  *newState*: "String" This is the state the client will be in after
      applying the set of changes to the old state.

   o  *hasMoreUpdates*: "Boolean" If "true", the client may call
      _getThreadUpdates_ again with the _newState_ returned to get
      further updates.  If "false", _newState_ is the current server
      state.

   o  *changed*: "String[]" An array of thread ids where the list of
      messages within the thread has changed between the old state and
      the new state, and the thread currently has at least one message
      in it.

   o  *removed*: "String[]" An array of thread ids where the list of
      messages within the thread has changed since the old state, and
      there are now no messages in the thread.

   If a _maxChanges_ is supplied, or set automatically by the server,
   the server MUST ensure the number of ids returned across _changed_
   and _removed_ does not exceed this limit.  If there are more changes
   than this between the client's state and the current server state,
   the update returned SHOULD generate an update to take the client to
   an intermediate state, from which the client can continue to call
   _getThreadUpdates_ until it is fully up to date.  If it is unable to
   calculate an intermediate state, it MUST return a
   "cannotCalculateChanges" error response instead.

   If a thread has been modified AND deleted since the oldState, the
   server SHOULD just return the id in the _removed_ response, but MAY
   return it in the changed response as well.  If a thread has been
   created AND deleted since the oldState, the server SHOULD remove the
   thread id from the response entirely, but MAY include it in the
   _removed_ response.

   The following errors may be returned instead of the _threadUpdates_
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds to a valid account, but the account does not support this
   data type.

   "invalidArguments": Returned if the request does not include one of
   the required arguments, or one of the arguments is of the wrong type,
   or otherwise invalid.  A _description_ property MAY be present on the
   response object to help debug with an explanation of what the problem
   was.

   "cannotCalculateChanges": Returned if the server cannot calculate the
   changes from the state string given by the client.  Usually due to
   the client's state being too old, or the server being unable to
   produce an update to an intermediate state when there are too many
   updates.  The client MUST invalidate its Thread cache.

5.  Messages

   Just like in IMAP, a message is *immutable* except for the boolean
   "isXXX" status properties and the set of mailboxes it is in.  This
   allows for more efficient caching of messages, and gives easier
   backwards compatibility for servers implementing an IMAP interface to
   the same data.

   JMAP completely hides the complexities of MIME.  All special
   encodings of either headers or textual body parts, such as base64
   [2], or RFC 2047 [3] encoding of non-ASCII characters, MUST be fully
   decoded into UTF-8.

   A *Message* object has the following properties:

   o  *id*: "String" The id of the message.

   o  *blobId*: "String" The id representing the raw [RFC5322] message.
      This may be used to download the original message or to attach it
      directly to another message etc.

   o  *threadId*: "String" The id of the thread to which this message
      belongs.

   o  *mailboxIds*: "String[]" (Mutable) The ids of the mailboxes the
      message is in.  A message MUST belong to one or more mailboxes at
      all times (until it is deleted).

   o  *keywords*: "String[Boolean]" (Mutable) A set of keywords that
      apply to the message.  The set is represented as an object, with
      the keys being the _keywords_. The value for each key in the
      object MUST be "true".  Keywords are shared with IMAP.  The six
      system keywords from IMAP are treated specially.  The following
      four keywords have their first character changed from "\" in IMAP
      to "$" in JMAP and have particular semantic meaning:

      *  "$Draft": The message is a draft the user is composing.

      *  "$Seen": The message has been read.

      *  "$Flagged": The message has been flagged for urgent/special
         attention.

      *  "$Answered": The message has been replied to.

      The IMAP "\Recent" keyword is not exposed via JMAP.  The IMAP
      "\Deleted" keyword is also not present: IMAP uses a delete+expunge
      model, which JMAP does not.  Any message with the "\Deleted"
      keyword MUST NOT be visible via JMAP.  Users may add arbitrary
      keywords to a message.  For compatibility with IMAP, a keyword is
      a (case-sensitive) string of 1-255 characters in the ASCII subset
      %x21-%x127 (excludes control chars and space), and MUST NOT
      include any of these characters: "()]{%*"\" The IANA Keyword
      Registry [4] as established in [RFC5788] assigns semantic meaning
      to some other keywords in common use.  New keywords may be
      established here in the future.  In particular, note:

      *  "$Forwarded": The message has been forwarded.

      *  "$Phishing": The message is highly likely to be phishing.
         Clients SHOULD warn users to take care when viewing this
         message and disable links and attachments.

      *  "$Junk": The message is definitely spam.  Clients SHOULD set
         this flag when users report spam to help train automated spam-
         detection systems.

      *  "$NotJunk": The message is definitely not spam.  Clients SHOULD
         set this flag when users indicate a message is legitimate, to
         help train automated spam-detection systems.

   o  *hasAttachment*: "Boolean" Does the message have any attachments?

   o  *headers*: "String[String]" A map of lower-cased header name to
      (decoded) header value for all headers in the message.  For
      headers that occur multiple times (e.g.  "Received"), the values
      are concatenated with a single new line ("\n") character in
      between each one.

   o  *sender*: "Emailer|null" An Emailer object (see below) containing
      the name/email from the parsed "Sender" header of the email.  If
      the email doesn't have a "Sender" header, this is "null".

   o  *from*: "Emailer[]|null" An array of name/email objects (see
      below) representing the parsed "From" header of the email, in the
      same order as they appear in the header.  If the email doesn't
      have a "From" header, this is "null".  If the header exists but
      does not have any content, the response is an array of zero
      length.

   o  *to*: "Emailer[]|null" An array of name/email objects (see below)
      representing the parsed "To" header of the email, in the same
      order as they appear in the header.  If the email doesn't have a
      "To" header, this is "null".  If the header exists but does not
      have any content, the response is an array of zero length.

   o  *cc*: "Emailer[]|null" An array of name/email objects (see below)
      representing the parsed "Cc" header of the email, in the same
      order as they appear in the header.  If the email doesn't have a
      "Cc" header, this is "null".  If the header exists but does not
      have any content, the response is an array of zero length.

   o  *bcc*: "Emailer[]|null" An array of name/email objects (see below)
      representing the parsed "Bcc" header of the email.  If the email
      doesn't have a "Bcc" header (which will be true for most emails
      outside of the Sent mailbox), this is "null".  If the header
      exists but does not have any content, the response is an array of
      zero length.

   o  *replyTo*: "Emailer[]|null" An array of name/email objects (see
      below) representing the parsed "Reply-To" header of the email, in
      the same order as they appear in the header.  If the email doesn't
      have a "Reply-To" header, this is "null".  If the header exists
      but does not have any content, the response is an array of zero
      length.

   o  *subject*: "String" The subject of the message.

   o  *date*: "Date" The date the message was sent (or saved, if the
      message is a draft).

   o  *size*: "Number" The size in bytes of the whole message as counted
      by the server towards the user's quota.

   o  *preview*: "String" Up to 256 characters of the beginning of a
      plain text version of the message body.  This is intended to be
      shown as a preview line on a mailbox listing, and the server may
      choose to skip quoted sections or salutations to return a more
      useful preview.

   o  *textBody*: "String" The plain text body part for the message.  If
      there is only an HTML version of the body, a plain text version
      MUST be generated from this; the exact method of conversion in
      this case is not defined and is server-specific.  If there is
      neither a "text/plain" nor a "text/html" body part, this MUST be
      the empty string.

   o  *htmlBody*: "String|null" The HTML body part for the message if
      present.

   o  *attachments*: "Attachment[]|null" An array of attachment objects
      (see below) detailing all the attachments to the message.

   o  *attachedMessages*: "String[Message]|null" An object mapping
      attachment id (as found in the "attachments" property) to a
      *Message* object with the following properties, for each [RFC5322]
      message attached to this one:

      *  headers

      *  from

      *  to

      *  cc

      *  bcc

      *  replyTo
      *  subject

      *  date

      *  textBody

      *  htmlBody

      *  attachments

      *  attachedMessages

   An *Emailer* object has the following properties:

   o  *name*: "String" The name of the sender/recipient.  If a name
      cannot be extracted for an email, this property SHOULD be the
      empty string.

   o  *email*: "String" The email address of the sender/recipient.  This
      MUST be of the form ""<mailbox>@<host>"" If a "host" or even
      "mailbox" cannot be extracted for an email, the empty string
      SHOULD be used for this part (so the result MUST always still
      contain an ""@"" character).

   Group information and comments from the RFC 5322 header MUST be
   discarded when converting into an Emailer object.

   Example array of Emailer objects:

            [
                {name:"Joe Bloggs", email:"joeb@example.com"},
                {name:"", email:"john@example.com"},
                {name:"John Smith", email: "john@"}
            ]

   An *Attachment* object has the following properties:

   o  *blobId*: "String" The id of the binary data.

   o  *type*: "String" The content-type of the attachment.

   o  *name*: "String|null" The full file name, e.g.
      "myworddocument.doc", if available.

   o  *size*: "Number" The size, in bytes, of the attachment when fully
      decoded (i.e. the number of bytes in the file the user would
      download).

   o  *cid*: "String|null" The id used within the message body to
      reference this attachment.  This is only unique when paired with
      the message id, and has no meaning without reference to that.

   o  *isInline*: "Boolean" True if the attachment is referenced by a
      "cid:" link from within the HTML body of the message.

   o  *width*: "Number|null" (optional, server MAY omit if not
      supported) The width (in px) of the image, if the attachment is an
      image.

   o  *height*: "Number|null" (optional, server MAY omit if not
      supported) The height (in px) of the image, if the attachment is
      an image.

5.1.  getMessages

   Messages can only be fetched explicitly by id.  To fetch messages,
   make a call to "getMessages".  It takes the following arguments:

   o  *accountId*: "String|null" The id of the account to use for this
      call.  If not given, defaults to the primary account.

   o  *ids*: "String[]" An array of ids for the messages to fetch.

   o  *properties*: "String[]|null" A list of properties to fetch for
      each message.  If "null", all properties will be fetched.

   The "id" property is always returned, regardless of whether it is in
   the list of requested properties.  The possible values for
   "properties" can be found above in the description of the Message
   object.  In addition to this, the client may request the following
   special values:

   o  *body*: If ""body"" is included in the list of requested
      properties, it will be interpreted by the server as a request for
      ""htmlBody"" if the message has an HTML part, or ""textBody""
      otherwise.

   o  *headers.property*: Instead of requesting all the headers (by
      requesting the ""headers"" property, the client may specify the
      particular headers it wants using the "headers.property-name"
      syntax, e.g. ""headers.x-spam-score", "headers.x-spam-hits"").
      The server will return a _headers_ property but with just the
      requested headers in the object rather than all headers.  If
      ""headers"" is requested, the server MUST ignore the individual
      header requests and just return all headers.  If a requested
      header is not present in the message, it MUST not be present in
      the _headers_ object.  Header names are case-insensitive.

   The response to _getMessages_ is called _messages_. It has the
   following arguments:

   o  *accountId*: "String" The id of the account used for the call.

   o  *state*: "String" A string encoding the current state on the
      server.  This string will change if any messages change (that is,
      a new message arrives, a change is made to one of the mutable
      properties, or a message is deleted).  It can be passed to
      _getMessageUpdates_ to efficiently get the list of changes from
      the previous state.

   o  *list*: "Message[]" An array of Message objects for the requested
      message ids.  This may not be in the same order as the ids were in
      the request.

   o  *notFound*: "String[]|null" An array of message ids requested
      which could not be found, or "null" if all ids were found.

   The following errors may be returned instead of the _messages_
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds to a valid account, but the account does not support this
   data type.

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

   "invalidArguments": Returned if the request does not include one of
   the required arguments, or one of the arguments is of the wrong type,
   or otherwise invalid.  A _description_ property MAY be present on the
   response object to help debug with an explanation of what the problem
   was.

   Example request:

 ["getMessages", {
   "ids": [ "f123u456", "f123u457" ],
   "properties": [ "threadId", "mailboxIds", "from", "subject", "date" ]
 }, "#1"]
   and response:

       ["messages", {
         "state": "41234123231",
         "list": [
           {
             messageId: "f123u457",
             threadId: "ef1314a",
             mailboxIds: [ "f123" ],
             from: [{name: "Joe Bloggs", email: "joe@bloggs.com"}],
             subject: "Dinner on Thursday?",
             date: "2013-10-13T14:12:00Z"
           }
         ],
         notFound: [ "f123u456" ]
       }, "#1"]

5.2.  getMessageUpdates

   If a call to _getMessages_ returns with a different _state_ string in
   the response to a previous call, the state of the messages has their first character changed on the server.  For example, a new message may have been
   delivered, or an existing message may from "\" in IMAP
      to "$" in JMAP and have changed mailboxes. particular semantic meaning:

      *  "$Draft": The _getMessageUpdates_ call allows message is a client to efficiently update
   the state of any cached messages to match the new state on the
   server.  It takes draft the following arguments:

   o  *accountId*: "String|null" user is composing.

      *  "$Seen": The id of the account to use for this
      call.  If not given, defaults to the primary account.

   o  *sinceState*: "String" message has been read.

      *  "$Flagged": The current state of the client.  This is
      the string that was returned as the _state_ argument in the
      _messages_ response. message has been flagged for urgent/special
         attention.

      *  "$Answered": The server will return the changes made
      since this state.

   o  *maxChanges*: "Number|null" message has been replied to.

      The maximum number of changed messages
      to return in the response. IMAP "\Recent" keyword is not exposed via JMAP.  The server MAY choose to clamp this
      value to a particular maximum or set a maximum if none IMAP
      "\Deleted" keyword is given by
      the client.  If supplied by the client, also not present: IMAP uses a delete+expunge
      model, which JMAP does not.  Any message with the value "\Deleted"
      keyword MUST NOT be visible via JMAP.  Users may add arbitrary
      keywords to a
      positive integer greater than 0.  If message.  For compatibility with IMAP, a value outside of this range keyword is given,
      a (case-sensitive) string of 1-255 characters in the server ASCII subset
      %x21-%x7e (excludes control chars and space), and MUST reject the call with an
      "invalidArguments" error.

   o  *fetchRecords*: "Boolean|null" If true, immediately after
      outputting a _messageUpdates_ response, an implicit call will NOT include
      any of these characters: "( ) { ] % * " \" The IANA Keyword
      Registry [2] as established in [RFC5788] assigns semantic meaning
      to some other keywords in common use.  New keywords may be
      made to _getMessages_ with a list of all message ids
      established here in the
      _changed_ argument of the response as the _ids_ argument, and the
      _fetchRecordProperties_ argument as the _properties_ argument.

   o  *fetchRecordProperties*: "String[]|null" The list of properties to
      fetch on any fetched messages.  See _getMessages_ for a full
      description. future.  In particular, note:

      *  "$Forwarded": The response to _getMessageUpdates_ is called _messageUpdates_. It message has the following arguments:

   o  *accountId*: "String" been forwarded.

      *  "$Phishing": The id of the account used for the call.

   o  *oldState*: "String" This message is the _sinceState_ argument echoed
      back; the state from which the server highly likely to be phishing.
         Clients SHOULD warn users to take care when viewing this
         message and disable links and attachments.

      *  "$Junk": The message is returning changes.

   o  *newState*: "String" This definitely spam.  Clients SHOULD set
         this flag when users report spam to help train automated spam-
         detection systems.

      *  "$NotJunk": The message is the state the client will be in after
      applying the definitely not spam.  Clients SHOULD
         set of changes this flag when users indicate a message is legitimate, to the old state.
         help train automated spam-detection systems.

   o  *hasMoreUpdates*:  *hasAttachment*: "Boolean" If "true", (immutable; server-set) This is "true"
      if and only if the client may call
      _getMessageUpdates_ again with _attachments_ property for the _newState_ returned to get
      further updates.  If "false", _newState_ Message contains
      at least one entry where _isInline_ is the current server
      state. "false".

   o  *changed*: "String[]" An array  *headers*: "String[String]" (immutable; default: "{}") A map of message ids
      lower-cased header name to (decoded) header value for messages all headers
      in the message.  For headers that
      have either been created or had their state change, and occur multiple times (e.g.
      "Received"), the values are not
      currently deleted. concatenated with a single new line
      ("\n") character in between each one.

   o  *removed*: "String[]"  *sender*: "Emailer|null" (immutable; default: "null") An array Emailer
      object (see below) containing the name/email from the parsed
      "Sender" header of message ids for messages that
      have been deleted since the oldState. email.  If the email doesn't have a _maxChanges_
      "Sender" header, this is supplied, or set automatically by the server,
   the server MUST ensure the number "null".

   o  *from*: "Emailer[]|null" (immutable; default: "null") An array of ids returned across _changed_
   and _removed_ does not exceed this limit.  If there are more changes
   than this between
      name/email objects (see below) representing the client's state and parsed "From"
      header of the current server state, email, in the update returned SHOULD generate an update to take same order as they appear in the client to
   an intermediate state, from which
      header.  If the client can continue to call
   _getMessageUpdates_ until it email doesn't have a "From" header, this is fully up to date.
      "null".  If it the header exists but does not have any content, the
      response is unable to
   calculate an intermediate state, it MUST return a
   "cannotCalculateChanges" error response instead.

   If a message has been modified AND deleted since the oldState, array of zero length.

   o  *to*: "Emailer[]|null" (immutable; default: "null") An array of
      name/email objects (see below) representing the
   server SHOULD just return parsed "To" header
      of the id email, in the _removed_ response, but MAY
   return it same order as they appear in the changed response as well. header.  If a message has been
   created AND deleted since
      the oldState, the server SHOULD remove email doesn't have a "To" header, this is "null".  If the
   message id from
      header exists but does not have any content, the response entirely, but MAY include it in is an
      array of zero length.

   o  *cc*: "Emailer[]|null" (immutable; default: "null") An array of
      name/email objects (see below) representing the
   _removed_ response, and (if in parsed "Cc" header
      of the _removed_ response) MAY included
   it email, in the _changed_ response same order as well.

   The following errors may be returned instead of they appear in the _messageUpdates_
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with header.  If
      the request, but it does not correspond to email doesn't have a valid account.

   "accountNotSupportedByMethod": Returned if "Cc" header, this is "null".  If the _accountId_ given
   corresponds to a valid account,
      header exists but the account does not support this
   data type.

   "invalidArguments": Returned if have any content, the request does not include one response is an
      array of
   the required arguments, or one zero length.

   o  *bcc*: "Emailer[]|null" (immutable; default: "null") An array of
      name/email objects (see below) representing the arguments is parsed "Bcc"
      header of the wrong type,
   or otherwise invalid.  A _description_ property MAY be present on email.  If the
   response object to help debug with an explanation email doesn't have a "Bcc" header
      (which will be true for most emails outside of what the problem
   was.

   "cannotCalculateChanges": Returned if Sent mailbox),
      this is "null".  If the server cannot calculate header exists but does not have any
      content, the
   changes from response is an array of zero length.

   o  *replyTo*: "Emailer[]|null" (immutable; default: "null") An array
      of name/email objects (see below) representing the state string given by parsed "Reply-
      To" header of the client.  Usually due to email, in the client's state being too old, or same order as they appear in the server being unable to
   produce an update to an intermediate state when there are too many
   updates.  The client MUST invalidate its Message cache.

5.3.  setMessages

   The _setMessages_ method encompasses:

   o  Creating a draft message

   o  Sending a message

   o  Changing
      header.  If the flags of a message (unread/flagged status)

   o  Adding/removing a message to/from mailboxes (moving email doesn't have a message)

   o  Deleting messages

   It takes "Reply-To" header, this is
      "null".  If the following arguments: header exists but does not have any content, the
      response is an array of zero length.

   o  *accountId*: "String|null"  *subject*: "String" (immutable; default: """") The id subject of the account to use for this
      call.
      message.  If not given, none, defaults to the primary account. empty string, not "null".

   o  *ifInState*: "String|null" This  *date*: "Date" (immutable; default: time of creation on server)
      The date the message was sent (or saved, if the message is a state string
      draft).

   o  *size*: "Number" (immutable; server-set) The size in bytes of the
      whole message as returned counted by the _getMessages_ method.  If supplied, the string must match the
      current state, otherwise the method will be aborted and a
      "stateMismatch" error returned.  If "null", any changes will be
      applied to server towards the current state. user's quota.

   o  *create*: "String[Message]|null" A map  *preview*: "String" (immutable; server-set) Up to 256 characters
      of _creation id_ (an
      arbitrary string set by the client) to Message objects (see below
      for beginning of a detailed description).

   o  *update*: "String[Message]|null" A map plain text version of the message id body.
      This is intended to objects
      containing be shown as a preview line on a mailbox
      listing, and the properties server may choose to update for that Message. skip quoted sections or
      salutations to return a more useful preview.

   o  *destroy*: "String[]|null" A list of ids  *textBody*: "String" (immutable; default: """") The plain text
      body part for Message objects to
      permanently delete.

   Each create, update or destroy the message.  If there is considered only an atomic unit.  It HTML version of
      the body, a plain text version MUST be generated from this; the
      exact method of conversion in this case is not defined and is
      server-specific.  If there is
   permissible neither a "text/plain" nor a "text/
      html" body part, this MUST be the empty string.

   o  *htmlBody*: "String|null" (immutable; default: "null") The HTML
      body part for the server to commit some message if present.

   o  *attachments*: "Attachment[]|null" (default: "null") An array of
      attachment objects (see below) detailing all the changes but not
   others, however it is not permissible to only commit part of an
   update attachments to a single record (e.g. update the _keywords_ field but not
      the _mailboxIds_ field, if both are supplied message.

   o  *attachedMessages*: "String[Message]|null" (immutable; server-set)
      An object mapping attachment id (as found in the update object for
   a message).

   If "attachments"
      property) to a create, update or destroy is rejected, *Message* object with the appropriate error
   MUST be added following properties, for
      each [RFC5322] message attached to the notCreated/notUpdated/notDestroyed this one:

      *  headers

      *  from

      *  to

      *  cc

      *  bcc
      *  replyTo

      *  subject

      *  date

      *  textBody

      *  htmlBody

      *  attachments

      *  attachedMessages

      This property of
   the response and is set by the server MUST continue to based on the next create/update/
   destroy.  It does not terminate _attachments_
      property.

   An *Emailer* object has the method. following properties:

   o  *name*: "String" The name of the sender/recipient.  If an id given a name
      cannot be found, extracted for an email, this property SHOULD be the update or destroy
      empty string.

   o  *email*: "String" The email address of the sender/recipient.  This
      MUST be
   rejected with a "notFound" set error.

5.3.1.  Saving of the form ""<mailbox>@<host>"" If a draft

   Creating messages via "host" or even
      "mailbox" cannot be extracted for an email, the _setMessages_ method is only empty string
      SHOULD be used for creating
   draft messages this part (so the result MUST always still
      contain an ""@"" character).

   Group information and sending them.  For delivering/importing a complete
   [RFC5322] message, use comments from the "importMessages" method.

   The properties RFC 5322 header MUST be
   discarded when converting into an Emailer object.

   Example array of the Message Emailer objects:

            [
                {name:"Joe Bloggs", email:"joeb@example.com"},
                {name:"", email:"john@example.com"},
                {name:"John Smith", email: "john@"}
            ]

   An *Attachment* object submitted for creation MUST
   conform to has the following conditions:

   o  *id*: This property MUST NOT be included.  It is set by the server
      upon creation. properties:

   o  *blobId*: This property MUST NOT be included.  It is set by "String" The id of the
      server upon creation. binary data.

   o  *threadId*: This property MUST NOT be included.  It is set by  *type*: "String" The content-type of the
      server upon creation. attachment.

   o  *mailboxIds*: This property MUST be included.  *name*: "String|null" The value MUST
      include full file name, e.g.
      "myworddocument.doc", if available.

   o  *size*: "Number" The size, in bytes, of the id attachment when fully
      decoded (i.e. the number of either bytes in the mailbox with "role == "drafts"" (to
      save a draft) or file the mailbox with "role == "outbox"" (to send user would
      download).

   o  *cid*: "String|null" The id used within the
      message).  If message body to
      reference this mailbox does not have "mustBeOnlyMailbox ==
      true", others may be included too.

   o  *keywords*: attachment.  This property MUST be included.  It MUST include is only unique when paired with
      the
      "$Draft" keyword message id, and SHOULD also include "$Seen". has no meaning without reference to that.

   o  *hasAttachment*: This property MUST NOT be included.  It  *isInline*: "Boolean" True if the attachment is set referenced by a
      "cid:" link from within the server upon creation based on HTML body of the attachments property. message.

   o  *headers*: Optional.  *width*: "Number|null" (optional, server MAY omit if not
      supported) The keys MUST only contain the characters
      a-z (lower-case only), 0-9 and hyphens.

   o  *from*: Optional.  Overrides a "From" in the _headers_.

   o  *to*: Optional.  Overrides a "To" in width (in px) of the _headers_.

   o  *cc*: Optional.  Overrides a "Cc" in image, if the _headers_. attachment is an
      image.

   o  *bcc*: Optional.  Overrides a "Bcc" in  *height*: "Number|null" (optional, server MAY omit if not
      supported) The height (in px) of the _headers_.

   o  *replyTo*: Optional.  Overrides a "Reply-To" in image, if the _headers_.

   o  *subject*: Optional.  Defaults to attachment is
      an image.

   To add an attachment, the empty string ("""").

   o  *date*: Optional.  If included, file must first be uploaded using the server SHOULD wait until
   standard upload mechanism; this
      time to send will give the message (once moved client a blobId that
   may be used to identify the outbox mailbox).
      Until it is sent, the send file.  The "cid" property may be cancelled assigned
   by moving the message
      back out of the outbox mailbox.  If the date client, and is in solely used for matching up with "cid:<id>"
   links inside the past, "htmlBody".

   The following JMAP methods are supported:

4.1.  getMessages

   Standard _getFoos_ method, except the
      message must be sent immediately.  A client may find out if use the
      server supports delayed sending by querying following
   pseudo values in the server's
      _capabilities_ object (see section 1). _properties_ argument:

   o  *size*: This MUST NOT be included.  It  *body*: If ""body"" is set by included in the server upon
      creation.

   o  *preview*: This list of requested
      properties, it MUST NOT be included.  It is set interpreted by the server
      upon creation.

   o  *textBody*: Optional.  If not supplied and an htmlBody is, the
      server SHOULD generate as a text version request for
      ""htmlBody"" if the message from the has an HTML body.

   o  *htmlBody*: Optional. part, or ""textBody""
      otherwise.

   o  *attachments*: Optional.  An array  *headers.property*: Instead of Attachment objects detailing requesting all the attachments to headers (by
      requesting the message.  To add an attachment, ""headers"" property, the
      file must first be uploaded client may specify the
      particular headers it wants using the standard upload mechanism;
      this will give "headers.property-name"
      syntax, e.g. ""headers.x-spam-score", "headers.x-spam-hits"").
      The server MUST return a _headers_ property but with just the client
      requested headers in the object rather than all headers.  If
      ""headers"" is requested, the server MUST ignore the individual
      header requests and just return all headers.  If a blobId that may be used to identify requested
      header is not present in the file.  The "cid" property may message, it MUST NOT be assigned by present in
      the client, _headers_ object.  Header names are case-insensitive.

4.1.1.  Example

   Request:

 ["getMessages", {
   "ids": [ "f123u456", "f123u457" ],
   "properties": [ "threadId", "mailboxIds", "from", "subject", "date" ]
 }, "#1"]

   and
      is solely used for matching up response:

       ["messages", {
         "accountId": "abc",
         "state": "41234123231",
         "list": [
           {
             id: "f123u457",
             threadId: "ef1314a",
             mailboxIds: { "f123": true },
             from: [{name: "Joe Bloggs", email: "joe@bloggs.com"}],
             subject: "Dinner on Thursday?",
             date: "2013-10-13T14:12:00Z"
           }
         ],
         notFound: [ "f123u456" ]
       }, "#1"]

4.2.  getMessageUpdates

   Standard _getFooUpdates_ method.

4.3.  getMessageList

   Standard _getFooList_ method, but with "cid:<id>" links inside the
      "htmlBody".  The server MAY change the cids upon sending. following additional
   arguments:

   o  *collapseThreads*: "Boolean" (default: "false") If any of "true",
      messages in the files specified same thread as a previous message in _attachments_ cannot be found, the
   creation MUST list
      (given the filter and sort order) will be rejected with an "invalidProperties" error.  An
   extra property SHOULD removed from the list.
      This means at most only one message will be included in the error list
      for any given thread.

4.3.1.  Filtering

   A *FilterOperator* object called
   "attachmentsNotFound", of type "String[]", which SHOULD be an array
   of the _blobId_ of every attachment that could not be found on has the
   server.  - *attachedMessages*: following properties:

   o  *operator*: "String" This MUST NOT be included.

   All optional properties default to "null" unless otherwise stated.
   Where included, properties MUST conform to the type given in one of the
   Message object definition.

   If any following strings:
      "AND"/"OR"/"NOT":

      *  *AND*: all of the properties are invalid, conditions must match for the server MUST reject filter to
         match.

      *  *OR*: at least one of the
   create with an "invalidProperties" error.  The Error object SHOULD
   contain a property called _properties_ conditions must match for the filter
         to match.

      *  *NOT*: none of type "String[]" that lists
   *all* the properties that were invalid. conditions must match for the filter to
         match.

   o  *conditions*: "(FilterCondition|FilterOperator)[]" The conditions
      to evaluate against each message.

   A *FilterCondition* object MAY also contain
   a _description_ property has the following properties, any of type which
   may be omitted:

   o  *inMailbox*: "String" with a user-friendly
   description of A mailbox id.  A message must be in this
      mailbox to match the problems.

   Other condition.

   o  *inMailboxOtherThan*: "String" A mailbox id.  A message be in any
      mailbox other than making sure it conforms this one to match the correct type, the server
   MUST NOT attempt to validate from/to/cc/bcc when saved as a draft. condition.  This is to ensure
      allow messages can be saved at any point.  Validation
   occurs when the user tries solely in trash/spam to send a message.

   If be easily excluded from a draft cannot
      search.

   o  *before*: "Date" The date of the message (as returned on the
      Message object) must be saved due before this date to match the user reaching their maximum
   mail storage quota, condition.

   o  *after*: "Date" The date of the creation MUST message (as returned on the
      Message object) must be rejected with a
   "maxQuotaReached" error.

5.3.2.  Updating messages

   Messages are mainly immutable, so on or after this date to update a draft match the
      condition.

   o  *minSize*: "Number" The size of the client must
   create a new message and delete in bytes (as returned
      on the old one.  This ensures that if Message object) must be equal to or greater than this
      number to match the draft is also being edited elsewhere, condition.

   o  *maxSize*: "Number" The size of the two will split into two
   different drafts to avoid data loss.

   Only message in bytes (as returned
      on the _mailboxIds_ and _keywords_ properties may Message object) must be modified, and
   they are subject less than this number to match the following constraints:
      condition.

   o  *mailboxIds*: The server MUST reject any attempt to add a message
      to  *allInThreadHaveKeyword*: "String" All messages (including this
      one) in the outbox that does not same thread as this message must have the "$Draft" given
      keyword with an
      "invalidProperties" error.

   o  *keywords*: The server MUST reject any attempt to add or remove match the "$Draft" flag condition.

   o  *someInThreadHaveKeyword*: "String" At least one message (possibly
      this one) in an update with an "invalidProperties" error.
      The server MAY have a maximum number of keywords it supports; if the change would exceed this, it MUST be rejected with a
      "tooManyKeywords" error.

   Note, a mailbox id may be a _creation id_ (see "setFoos" for a
   description of how same thread as this works).

   If any of message must have the properties given
      keyword to match the condition.

   o  *noneInThreadHaveKeyword*: "String" All messages (including this
      one) in the update are invalid (immutable and
   different same thread as this message must *not* have the given
      keyword to match the current server value, wrong type, invalid value for condition.

   o  *hasKeyword*: "String" This message must have the property - like a mailbox id for non-existent mailbox), given keyword to
      match the
   server MUST reject condition.

   o  *notKeyword*: "String" This message must not have the update with an "invalidProperties" error.  The
   Error object SHOULD contain a property called _properties_ of type
   "String[]" that lists *all* given
      keyword to match the properties that were invalid. condition.

   o  *hasAttachment*: "Boolean" The
   object MAY also contain a _description_ "hasAttachment" property of type "String"
   with a user-friendly description of the problems.

   If the _id_ given does not correspond to a Message in
      message must be identical to the value given
   account, reject the update with a "notFound" error.

   To *delete a message* to trash, simply change match the "mailboxIds"
   property so it is now in
      condition.

   o  *text*: "String" Looks for the mailbox with "role == "trash"", and
   remove all other mailbox ids.

5.3.3.  Sending messages

   To send a message, either create a new message directly into text in messages.  The server
      SHOULD look up text in the
   mailbox with "role == "outbox"" _from_, _to_, _cc_, _bcc_, _subject_,
      _textBody_, _htmlBody_ or move an existing draft into this
   mailbox.  At this point _attachments_ properties of the server will check that it has everything
   it needs for a valid message.  In particular, that it has a valid
   "From" address (and
      The server MAY extend the user has permission to use this From
   address), it has at least one address search to send to, and all addresses any additional textual
      property.

   o  *from*: "String" Looks for the text in To/Cc/Bcc are valid email addresses.  If it cannot send, it will
   reject the creation/update with an "invalidProperties" error.  The
   Error object SHOULD contain a _from_ property called _properties_ of type
   "String[]" that lists *all* the properties that were invalid.  The
   object SHOULD also contain a _description_
      message.

   o  *to*: "String" Looks for the text in the _to_ property of type the
      message.

   o  *cc*: "String"
   with a user-friendly description of Looks for the problems to present to text in the
   user.

   If _cc_ property of the message is accepted,
      message.

   o  *bcc*: "String" Looks for the server SHOULD *asynchronously*
   schedule text in the message to be sent *after* this method call is complete
   (note, this MAY occur before _bcc_ property of the next method
      message.

   o  *subject*: "String" Looks for the text in the same API request
   or after _subject_ property
      of the whole API request is complete).  This means that message.

   o  *body*: "String" Looks for the
   "newState" string text in the response represents a state where _textBody_ or
      _htmlBody_ property of the
   message is still message.

   o  *attachments*: "String" Looks for the text in the outbox.

   When attachments of
      the message is sent, message.  Server MAY handle text extraction when possible for
      the server different kinds of media.

   o  *header*: "String[]" The array MUST remove contain either one or two
      elements.  The first element is the message from name of the
   *outbox* and add it header to the *sent* mailbox, unless the user has
   indicated another preference. match
      against.  The version added to the sent mailbox
   MAY be different (for example have extra headers added by second (optional) element is the
   server), and so have a different id text to the version that was look for in
      the
   outbox. header.  If not supplied, the message has an "In-Reply-To" header, the server
   SHOULD add the "$Answered" keyword to all messages with the
   coresponding "Message-Id" matches simply if it
      _has_ a header at this point. of the given name.

   If zero properties are specified on the message has
   an "X-Forwarded-Message-Id" header, FilterCondition, the server SHOULD add
   condition MUST always evaluate to "true".  If multiple properties are
   specified, ALL must apply for the
   "$Forwarded" keyword condition to be "true" (it is
   equivalent to splitting the object into one-property conditions and
   making them all messages with the coresponding "Message-
   Id" header at this point. child of an AND filter operator).

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

   o  Text SHOULD be matched in a case-insensitive manner.

   o  Text contained in either reporting an error (normally (but matched) single or double quotes
      SHOULD be treated as a *phrase search*, that is a
   "bounce" email), match is
      required for that exact word or ensuring delivery sequence of words, excluding the message
      surrounding quotation marks.  Use "\"", "\'" and "\\" to the next hop.

5.3.4.  Cancelling match a send

   A message
      literal """, "'" and "\" respectively in a phrase.

   o  Outside of a phrase, white-space SHOULD be treated as dividing
      separate tokens that may be moved out of the *outbox* and back to the *drafts*
   mailbox using the standard update message mechanism, if it has not
   yet been sent at the time searched for separately in the method is called.  This
      message, but MUST cancel the
   queued send.  If all be present for the message has already been sent then it will have
   been deleted from the outbox, so the update will fail with a standard
   "notFound" error.

5.3.5.  Destroying messages

   If the _id_ given does not correspond to a Message in the given
   account, the server MUST reject match the destruction with
      filter.

   o  Tokens MAY be matched on a "notFound"
   error.

   Destroying whole-word basis using stemming (so for
      example a message removes it from all mailboxes to which it
   belonged. text search for "bus" would match "buses" but not
      "business").

   o  When emptying searching inside the trash, clients _htmlBody_ property, HTML tags and
      attributes SHOULD NOT destroy messages which
   are also in a mailbox other than trash.  For those messages, they
   should just remove the Trash mailbox from the message.

5.3.6.  Response be ignored.

4.3.2.  Sorting

   The response to _setMessages_ is called _messagesSet_. It has the following arguments:

   o  *accountId*: "String" The id of the account used properties MUST be supported for the call.

   o  *oldState*: "String|null" The state string that would have been
      returned by _getMessages_ before making the requested changes, or
      "null" if the server doesn't know what the previous state string
      was. sorting:

   o  *newState*: "String"  *date* - The state string that will now be date as returned by
      _getMessages_.

   o  *created*: "String[Message]" A map of the creation id to an object
      containing in the _id_, _blobId_, _threadId_, and _size_ Message object.

   The following properties SHOULD be supported for each successfully created Message. sorting:

   o  *updated*: "String[Message|null]"  *size* - The _keys_ size as returned in this map are the
      ids Message object.

   o  *from* - This is taken to be either the "name" part of all messages that were successfully updated.  If the server
      made any other changes to Emailer
      object, or if none then the record beyond those explicitly
      requested by "email" part of the client, Emailer object
      (see the _value_ for definition of the corresponding id from property in the map is an object containing Message object).
      If still none, consider the updated value of each property to be the *server changed*. Otherwise (if no properties changed on empty string.

   o  *to* - This is taken to be either the
      server other than those explicitly updated by "name" part of the client), *first*
      Emailer object, or if none then the
      value is "null".

   o  *destroyed*: "String[]" A list "email" part of Message ids for Messages that
      were successfully destroyed.

   o  *notCreated*: "String[SetError]" A map the *first*
      Emailer object (see the definition of creation id the to a
      SetError object for each property in the
      Message that failed object).  If still none, consider the value to be created.  The
      possible errors are defined above. the
      empty string.

   o  *notUpdated*: "String[SetError]" A map of Message id to a SetError
      object for each Message that failed  *subject* - This is taken to be updated.  The possible
      errors are defined above.

   o  *notDestroyed*: "String[SetError]" A map the subject of the Message id to a
      SetError object for each Message that failed to with
      any ignoring any leading "Fwd:"s or "Re:"s (case-insensitive
      match).

   o  *keyword:*"$keyword" - This value MUST be destroyed.  The
      possible errors are defined above.

   The following errors may considered "true" if the
      message has the keyword, or "false" otherwise.

   o  *allThreadKeyword:*"$keyword" - This value MUST be returned instead of considered
      "true" for the _messagesSet_
   response:

   "accountNotFound": Returned message if an _accountId_ was explicitly included
   with *all* of the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if messages in the _accountId_ given
   corresponds to a valid account, but same thread
      (regardless of mailbox) have the account does not support this
   data type.

   "accountReadOnly": Returned if keyword.

   o  *someThreadKeyword:*"$keyword" - This value MUST be considered
      "true" for the account has "isReadOnly == true".

   "invalidArguments": Returned message if one *any* of the arguments is messages in the same thread
      (regardless of mailbox) have the wrong
   type, or otherwise invalid.  A _description_ property keyword.

   The server MAY be present support sorting based on other properties as well.  A
   client can discover which properties are supported by inspecting the response
   server's _capabilities_ object to help debug with an explanation (see section 1).

   Example sort:

            `[ "someThreadKeyword:$Flagged desc", "date desc" ]

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

4.3.3.  Thread collapsing

   When "collapseThreads == true", then after filtering and sorting the
   message list, the list is further winnowed by removing any messages
   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 what the
   problem was.

   "stateMismatch": Returned if an _ifInState_ argument was supplied and
   it does not match result, at the current state.

5.4.  importMessages

   The _importMessages_ method adds [RFC5322] messages to a user's set position of messages.  The messages must the first be uploaded as a file using
   message in the
   standard upload mechanism.  It takes list that belongs to the thread.

4.3.4.  Response

   The _messageList_ response has the following arguments: additional argument:

   o  *accountId*: "String|null"  *collapseThreads*: "Boolean" The id of _collapseThreads_ value that was
      used when calculating the account to use message list for this call.  If "null", defaults to

4.4.  getMessageListUpdates

   Standard _getFooListUpdates_ method, with the primary account. following additional
   arguments:

   o  *messages*: "String[MessageImport]" A map of creation id (client
      specified) to MessageImport objects

   An *MessageImport* object  *collapseThreads*: "Boolean" (default: "false") The
      _collapseThreads_ argument that was used with _getMessageList_.

   The _messageListUpdates_ response has the following properties: additional
   arguments:

   o  *blobId*: "String"  *collapseThreads*: "Boolean" The id representing _collapseThreads_ value that was
      used when calculating the raw [RFC5322] message
      (see the file upload section).

   o  *mailboxIds* "String[]" The ids of the mailbox(es) to assign list for this call.

4.5.  setMessages

   Standard _setFoos_ method.  The _setMessages_ method encompasses:

   o  Creating a draft message to.

   o  *keywords*: "String[Boolean]"

   Adding to the outbox will send  Changing the flags of a message (unread/flagged status)

   o  Adding/removing a message to/from mailboxes (moving a message)

   o  Deleting messages

   When creating a message, as described in the
   _setMessages_ section.  The "$Draft" keyword MUST also be included if the message is being imported _headers_ property specifies extra
   headers to the outbox.

   The response add in addition to _importMessages_ is called _messagesImported_. It has any based off the following arguments:

   o  *accountId*: "String" parsed properties
   (like _from_/_to_/_subject_).  The id keys MUST only contain the
   characters a-z (lower-case only), 0-9 and hyphens.  If a header is
   included that conflicts with one of the account used for this call.

   o  *created*: "String[Message]" A map of other properties on the creation id to an
   Message object
      containing (e.g. _from_, _date_), the _id_, _blobId_, _threadId_ and _size_ properties
      for each successfully imported Message.

   o  *notCreated*: "String[SetError]" A map of creation id to a
      SetError value in the _headers_
   object for each Message that failed to MUST be created.  The
      possible errors are defined above. ignored.

   The following errors may be returned instead of server MAY also choose to set additional headers.  If not
   included, the _messageImported_
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included server MUST generate and set a "Message-Id" header in
   conformance with the request, but [RFC5322] section 3.6.4.

   Other than making sure it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds conforms to a valid account, but the account does not support this
   data type.

   "accountReadOnly": Returned if correct type, the account has "isReadOnly == true".

   "invalidArguments": Returned server
   MUST NOT attempt to validate _from_/_to_/_cc_/_bcc_ (e.g. checking if one of the arguments
   an email address is of valid) when creating a message.  This is to
   ensure draft messages can be saved at any point.

   Destroying a message removes it from all mailboxes to which it
   belonged.  To just delete a message to trash, simply change the wrong
   type, or otherwise invalid.  A "description"
   "mailboxIds" property MAY be present
   on so it is now in the response object to help debug mailbox with an explanation of what "role ==
   "trash"", and remove all other mailbox ids.

   When emptying the trash, clients SHOULD NOT destroy messages which
   are also in a mailbox other than trash.  For those messages, they
   SHOULD just remove the
   problem was.

   "notFound": Returned if Trash mailbox from the URL message.

   The following extra _SetError_ types are defined:

   For *create*:

   o  "attachmentNotFound": At least one blob id given in the "file" argument does not
   correspond to an internal file.

   "invalidMailboxes": Returned if one attachment
      doesn't exist.  An extra _notFound_ property of type "String[]"
      MUST be included in the mailbox ids cannot error object containing every _blobId_
      referenced in _attachments_ that could not be
   found, or an invalid combination of mailbox ids is specified.

   "maxQuotaReached": Returned if found on the server.

   o  "maxQuotaReached": The user has reached a server-defined limit on
      their mail quota
   so the message cannot be imported.

5.5.  copyMessages storage quota.

   For *update*:

   o  "tooManyKeywords": The only way change to move the message's keywords would
      exceed a server-defined maximum.

4.6.  importMessages

   The _importMessages_ method adds [RFC5322] messages *between* two different accounts is to
   copy them a user's set
   of messages.  The messages must first be uploaded as a file using the _copyMessages_ method, then once the copy has
   succeeded, delete the original.
   standard upload mechanism.  It takes the following arguments:

   o  *fromAccountId*:  *accountId*: "String|null" The id of the account to copy
      messages from. use for this
      call.  If "null", defaults to the primary account.

   o  *toAccountId*: "String|null"  *messages*: "String[MessageImport]" A map of creation id (client
      specified) to MessageImport objects

   A *MessageImport* object has the following properties:

   o  *blobId*: "String" The id representing the raw [RFC5322] message
      (see the file upload section).

   o  *mailboxIds* "String[Boolean]" The ids of the account mailbox(es) to copy
      assign this message to.  At least one mailbox MUST be given.

   o  *keywords*: "String[Boolean]" (default: "{}") The keywords to
      apply to the message.

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

   The server MAY forbid two messages to.  If "null", defaults to with the primary same exact [RFC5322]
   content, or even just with the same [RFC5322] Message-Id, to coexist
   within an account.

   o  *messages*: "String[MessageCopy]" A map of _creation id_  In this case, it should reject attempts to import
   a
      MessageCopy object. message considered a duplicate with an "alreadyExists" SetError.  A *MessageCopy*
   _messageId_ property of type "String" MUST be included on the error
   object has with the following properties:

   o  *messageId*: "String" The id of the message to be copied in existing message.

   If the
      "from" account.

   o  *mailboxIds*: "String[]" The ids of _blobId_, _mailboxIds_, or _keywords_ properties are invalid
   (e.g. missing, wrong type, id not found), the mailboxes (in server MUST reject the "to"
      account) to add
   import with an "invalidProperties" SetError.

   If the copied message to.

   o  *keywords*: "String[Boolean]" The _keywords_ property for cannot be imported because it would take the
      copy.

   The "from" account may
   over quota, the import should be rejected with a "maxQuotaReached"
   SetError.

   If the same blob referenced cannot be parsed as an [RFC5322] message, the "to" account to copy
   messages within
   server MUST reject the import with an account. "invalidMessage" SetError.

   The response to _copyMessages_ _importMessages_ is called _messagesCopied_. _messagesImported_. It has
   the following arguments:

   o  *fromAccountId*: "String" The id of the account messages were
      copied from.

   o  *toAccountId*:  *accountId*: "String" The id of the account messages were copied
      to. used for this call.

   o  *created*: "String[Message]|null" "String[Message]" A map of the creation id to an object
      containing the _id_, _blobId_, _threadId_ and _size_ properties
      for each successfully copied imported Message.

   o  *notCreated*: "String[SetError]|null" "String[SetError]" A map of creation id to a
      SetError object for each Message that failed to be copied, "null"
      if none. created.  The *SetError* may be one of the following types:

   "notFound": Returned if the messageId given can't be found.

   "invalidMailboxes": Returned if one of the mailbox ids cannot be
   found, or an invalid combination of mailbox ids is specified.

   "maxQuotaReached": Returned if the user has reached their mail quota
   so the message cannot be copied.
      possible errors are defined above.

   The following errors may be returned instead of the _messagesCopied_
   response:

   "fromAccountNotFound": Returned if a _fromAccountId_ was explicitly
   included with instead of the request, but it does not correspond to a valid
   account.

   "toAccountNotFound": _messageImported_
   response:

   "accountNotFound": Returned if a _toAccountId_ an _accountId_ was explicitly included
   with the request, but it does not correspond to a valid account.

   "fromAccountNoMail":

   "accountNotSupportedByMethod": Returned if the _fromAccountId_ _accountId_ given
   corresponds to a valid account, but does not contain any mail data.

   "toAccountNoMail": Returned if the _toAccountId_ given corresponds to
   a valid account, but account does not contain any mail data. support this
   data type.

   "accountReadOnly": Returned if the "to" account has "isReadOnly == true".

   "invalidArguments": Returned if one of the arguments is of the wrong
   type, or otherwise invalid.  A "description" property MAY be present
   on the response object object to help debug with an explanation of what the
   problem was.

4.7.  copyMessages

   The only way to move messages *between* two different accounts is to
   copy them using the _copyMessages_ method, then once the copy has
   succeeded, delete the original.  It takes the following arguments:

   o  *fromAccountId*: "String|null" The id of the account to copy
      messages from.  If "null", defaults to the primary account.

   o  *toAccountId*: "String|null" The id of the account to copy
      messages to.  If "null", defaults to the primary account.

   o  *messages*: "String[MessageCopy]" A map of _creation id_ to a
      MessageCopy object.

   A *MessageCopy* object has the following properties:

   o  *messageId*: "String" The id of the message to be copied in the
      "from" account.

   o  *mailboxIds*: "String[Boolean]" The ids of the mailboxes (in the
      "to" account) to add the copied message to.  At least one mailbox
      MUST be given.

   o  *keywords*: "String[Boolean]" (default: "{}") The _keywords_
      property for the copy.

   The server MAY forbid two messages 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 messages within
   an account.

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

   The response to help debug with an explanation of what the
   problem was.

6.  Identities

   A *Identity* object stores information about an email address (or
   domain) the user may send from. _copyMessages_ is called _messagesCopied_. It has the
   following properties: arguments:

   o  *id*:  *fromAccountId*: "String" The id of the identity.  This property is
      immutable. account messages were
      copied from.

   o  *name*:  *toAccountId*: "String" The "From" _name_ id of the client SHOULD use when
      creating a new message from this identity. account messages were copied
      to.

   o  *email*: "String" The "From" email address  *created*: "String[Message]|null" A map of the client MUST use
      when creating creation id to an
      object containing the _id_, _blobId_, _threadId_ and _size_
      properties for each successfully copied Message.

   o  *notCreated*: "String[SetError]|null" A map of creation id to a new message from this identity.  This property is
      immutable.
      SetError object for each Message that failed to be copied, "null"
      if none.

   The "email" property MAY alternatively *SetError* may be one of the form
      "*@example.com", in which case following types:

   "alreadyExists": Returned if the client may use any valid email
      address ending in "@example.com".

   o  *replyTo*: "String" The Reply-To value server forbids duplicates and the client SHOULD set when
      creating a new
   message from this identity.

   o  *bcc*: "String" The Bcc value already exists in the client SHOULD set when creating
      a new message from this identity.

   o  *textSignature*: target account.  A _messageId_ property
   of type "String" Signature the client SHOULD insert into
      new rich-text messages that will MUST be sending from this identity.
      Clients MAY ignore this and/or combine this included on the error object with a client-specific
      signature preference.

   o  *htmlSignature*: "String" Signature the client SHOULD insert into
      new HTML messages that will id of
   the existing message.

   "notFound": Returned if the _messageId_ given can't be sending from this identity.  This
      text MUST found.

   "invalidProperties": Returned if the _mailboxIds_ or _keywords_
   properties are invalid (e.g. missing, wrong type, id not found).

   "maxQuotaReached": Returned if the user has reached their mail quota
   so the message cannot be an HTML snippet to copied.

   The following errors may be inserted into the
      "<body></body>" section returned instead of the new email.  Clients MAY ignore this
      and/or combine this _messagesCopied_
   response:

   "fromAccountNotFound": Returned if a _fromAccountId_ was explicitly
   included with the request, but it does not correspond to a client-specific signature preference.

   o  *mayDeleteIdentity*: "Boolean" Is valid
   account.

   "toAccountNotFound": Returned if a _toAccountId_ was explicitly
   included with the user allowed request, but it does not correspond to delete this
      identity?  Servers may wish a valid
   account.

   "fromAccountNoMail": Returned if the _fromAccountId_ given
   corresponds to set this a valid account, but does not contain any mail data.

   "toAccountNoMail": Returned if the _toAccountId_ given corresponds to false for
   a valid account, but does not contain any mail data.

   "accountReadOnly": Returned if the user's
      username or other default address.

   Multiple identities with "to" account has "isReadOnly ==
   true".

   "invalidArguments": Returned if one of the same email address arguments is of the wrong
   type, or otherwise invalid.  A "description" property MAY exist, to allow
   for different settings be present
   on the user wants response object to pick between (for example help debug with different names/signatures).

6.1.  getIdentities

   Identities can either be fetched explicitly by id, or all an explanation of what the
   problem was.

5.  MessageSubmission

   The MessageSubmission object represents the submission of them at
   once.  To fetch identities, make a call message
   for delivery to "getIdentities".  It takes one or more recipients.  A *MessageSubmission* object
   has the following arguments: properties:

   o  *accountId*: "String|null"  *id*: "String" (immutable; server-set) The Account to fetch the identities
      for.  If "null", id of the primary account is used. message
      submission.

   o  *ids*: "String[]|null"  *identityId*: "String" (immutable) The ids id of the identities identity to fetch.  If
      "null", all identities in
      associate with this submission.

   o  *messageId*: "String" (immutable) The id of the account are be fetched. message to send.
      The response message being sent does not have to _getIdentities_ is called _identities_. It has the
   following arguments: be a draft, for example
      when "redirecting" an existing message to a different email
      address.

   o  *accountId*:  *threadId*: "String" (immutable; server-set) The thread id of the account used for
      message to send.  This is set by the call. server to the _threadId_
      property of the message referenced by the _messageId_.

   o  *state*: "String" A string encoding  *envelope*: "Envelope|null" (immutable; default: "null")
      Information for use when sending via SMTP.  An *Envelope* object
      has the current state on following properties:

      *  *mailFrom*: "Address" The email address to use as the
      server.  This string will change if return
         address in the SMTP submission, plus any identities change (that
      is, a new identity is created, a change is made parameters to an existing
      identity, or an identity is deleted).  It can be passed pass
         with the MAIL FROM address.  The JMAP server MAY allow the
         email to
      _getIdentityUpdates_ be the empty string.  When a JMAP server performs a
         message submission, it MAY use the same id string for the
         [RFC3461] ENVID parameter and the MessageSubmission object id.
         Servers that do this MAY replace a client-provided value for
         ENVID with a server-provided value.

      *  *rcptTo*: "Address[]" The email addresses to efficiently get send the list of changes from message
         to, and any RCPT TO parameters to pass with the previous state.

   o  *list*: "Identity[]" recipient.

      An array of *Address* object has the following properties:

      *  *email*: "String" The email address being represented by the Identity objects requested.
         object.  This will be the *empty array* if the _ids_ argument was as a "Mailbox" as used in the empty
      array, Reverse-path or contained only ids for identities that could not be
      found.

   o  *notFound*: "String[]|null" This array contains
         Foward-path of the ids passed MAIL FROM or RCPT TO command in [@!RFC5321

      *  *parameters*: "Object|null" Any parameters to send with the method for identities that do not exist,
         email (either mail-parameter or "null" if all
      requested ids were found.  It MUST be "null" if the _ids_ argument rcpt-parameter as appropriate,
         as specified in [RFC5321]).  If supplied, each key in the call was "null".

   The following errors may be returned instead of
         object is a parameter name, and the _identities_
   response:

   "accountNotFound": Returned value either the parameter
         value (type "String") or if an _accountId_ was explicitly included
   with the request, but it parameter does not correspond to take a valid account.

   "accountNotSupportedByMethod": Returned if value
         then "null".  For both name and value, any xtext or unitext
         encodings are removed ([RFC3461], [RFC6533]) and JSON string
         encoding applied.

      If the _accountId_ given
   corresponds to a valid account, but _envelope_ property is "null" or omitted on creation, the account does not support
      server MUST generate this
   data type.

   "invalidArguments": Returned from the referenced message as follows:

      *  *mailFrom*: The email in the _Sender_ header, if present,
         otherwise the _From_ header, if present, and no parameters.  If
         multiple addresses are present in one of the arguments these headers, or
         there is of more than one _Sender_/_From_ header, the wrong
   type, or server
         SHOULD reject the message as invalid but otherwise invalid.  A "description" property MAY be present
   on MUST take
         the response object to help debug with an explanation of what first email address in the
   problem was.

6.2.  getIdentityUpdates

   The _getIdentityUpdates_ call allows a client to efficiently update last _Sender_/_From_ header in
         the state [RFC5322] version of its cached identities to match the new state on message.  If the address found
         from this is not allowed by the identity associated with this
         submission, the
   server.  It takes _email_ property from the following arguments:

   o  *accountId*: "String|null" identity MUST be used
         instead.

      *  *rcptTo*: The id deduplicated set of email addresses from the account to use
         _To_, _Cc_ and _Bcc_ headers, if present, with no parameters
         for this
      call.  If "null", any of them.

   o  *sendAt*: "Date" (immutable; server-set) The date the primary account message was/
      will be used.

   o  *sinceState*: "String" The current state of released for delivery.  If the client.  This is client successfully used
      [RFC4865] FUTURERELEASE with the string that was returned as message, this MUST be the _state_ argument in time
      when the
      _identities_ response.  The server will return release the changes made
      since this state. message; otherwise it MUST be the
      time the MessageSubmission was created.

   o  *maxChanges*: "Number|null" The maximum number of Identity ids to
      return in  *undoStatus*: "String" (server-set) This represents whether the response.  The
      submission may be canceled.  This is server set and MUST be one of
      the following values:

      *  "pending": It MAY choose be possible to clamp cancel this value submission.

      *  "final": The message has been relayed to at least one recipient
         in a particular maximum or set a maximum if none manner that cannot be recalled.  It is given by the
      client.  If supplied by the client, the value MUST no longer possible
         to cancel this submission.

      *  "canceled": The message submission was canceled and will not be a positive
      integer greater than 0.  If a
         delivered to any recipient.

      On systems that do not support unsending, the value outside of this range is
      given,
      property will always be "final".  On systems that do support
      canceling submission, it will start as "pending", and MAY
      transition to "final" when the server MUST reject knows it definitely cannot
      recall the call with an "invalidArguments"
      error.

   o  *fetchRecords*: "Boolean|null" message, but MAY just remain "pending".  If "true", immediately after
      outputting an _identityUpdates_ response, an implicit call will be
      made in pending
      state, a client can attempt to cancel the submission by setting
      this property to "canceled"; if the update succeeds, the
      submission was successfully canceled and the message has not been
      delivered to _getidentities_ with any of the _changed_ property original recipients.

   o  *deliveryStatus*: "String[DeliveryStatus]|null" (server-set) This
      represents the delivery status for each of the
      response as message 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 _ids_ argument, and MessageSubmission object each time the _fetchRecordProperties_
      argument as status of any of
      the _properties_ argument.  If "false" or "null", no
      implicit call recipients changes, even if some recipients are still being
      retried.  This value is made.

   The response a map from the email address of each
      recipient to _getIdentityUpdates_ is called _identityUpdates_. It a _DeliveryStatus_ object.  A *DeliveryStatus* object
      has the following arguments:

   o  *accountId*: properties:

      *  *smtpReply*: "String" The id of SMTP reply string returned for this
         recipient when the account used server last tried to relay the message, or
         in a later DSN response for the call.

   o  *oldState*: "String" message.  This is SHOULD be the _sinceState_ argument echoed
      back;
         response to the state from which RCPT TO stage, unless this was accepted and the server is returning changes.

   o  *newState*: "String" This is
         message as a whole rejected at the state end of the client will be DATA stage, in after
      applying
         which case the set of changes DATA stage reply SHOULD be used instead.  Multi-
         line SMTP responses should be concatenated to a single string
         as follows:

         +  The hyphen following the old state.

   o  *hasMoreUpdates*: "Boolean" If "true", SMTP code on all but the client may call
      _getIdentityUpdates_ again last line
            is replaced with a space.

         +  Any prefix in common with the _newState_ returned to get
      further updates.  If "false", _newState_ first line is stripped from
            lines after the first.

         +  CRLF is replaced by a space.

         For example:

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

         would become:

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

         For messages relayed via an alternative to SMTP, the current server
      state.

   o  *changed*: "String[]" An array MAY
         generate a synthetic string representing the status instead.
         If it does this, the string MUST be of Identity ids where the following form:

         +  A 3-digit SMTP reply code, as defined in [RFC5321], section
            4.2.3.

         +  Then a single space character.

         +  Then an SMTP Enhanced Mail System Status Code as defined in
            [RFC3463], with a property registry defined in [RFC5248].

         +  Then a single space character.

         +  Then an implementation-specific information string with a
            human readable explanation of the identity has changed between the old state and the new state,
      or response.

      *  *delivered*: "String" Represents whether the identity message has been created, and
         successfully delivered to the identity has not been
      destroyed.

   o  *removed*: "String[]" An array recipient.  This MUST be one of Identity ids for identities
      which have been destroyed since
         the old state.

   If a _maxChanges_ following values:

         +  "queued": The message is supplied, or set automatically by the server, in a local mail queue and status
            will change once it exits the server must try local mail queues.  The
            _smtpReply_ property may still change.

         +  "yes": The message was successfully delivered to limit the number mailbox
            of ids across _changed_ and
   _removed_ to the number given.  If there are more changes than this
   between the client's state and the current server state, the update
   returned MUST take the client recipient.  The _smtpReply_ property is final.

         +  "no": Message delivery to an intermediate state, from which the client can continue to call _getIdentityUpdates_ until it recipient permanently failed.
            The _smtpReply_ property is
   fully up to date. final.

         +  "unknown": The server MAY return more ids than the
   _maxChanges_ total if this final delivery status is required for unknown, (e.g. it to be able to produce
   an update
            was relayed to an intermediate state, but it SHOULD try to keep it
   close external machine and no further
            information is available).  The _smtpReply_ property may
            still change if a DSN arrives.

         Note, successful relaying to the maximum requested.

   If an identity has been modified AND deleted since the oldState, the external SMTP server should just return the id in the _removed_ array, but MAY
   return it in the _changed_ array SHOULD NOT
         be taken as well.  If an identity has been
   created AND deleted since the oldState, the server SHOULD remove the
   identity id from the response entirely, but MAY include it in indication that the
   _removed_ array.

   The following errors may be returned instead of message has successfully
         reached the "identityUpdates"
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with final mailbox.  In this case though, the request, but it does not correspond to server MAY
         receive a valid account.

   "accountNotSupportedByMethod": Returned DSN response, if requested.  If a DSN is received for
         the _accountId_ given
   corresponds recipient with Action equal to a valid account, but "delivered", as per
         [RFC3464] section 2.3.3, then the account does not support this
   data type.

   "invalidArguments": Returned _delivered_ property SHOULD
         be set to "yes"; if the request does not include one of
   the required arguments, or one of the arguments is of Action equals "failed", the wrong type,
   or otherwise invalid.  A "description" property MAY
         SHOULD be present on the
   response object set to help debug with an explanation "no".  Receipt of what the problem
   was.

   "cannotCalculateChanges": Returned if the any other DSN SHOULD NOT
         affect this property.  The server cannot calculate the
   changes from the state string given by MAY also set this property
         based on other feedback channels.

      *  *displayed*: "String" Represents whether the client.  Usually due message has been
         displayed to the client's state being too old, or the server being unable to
   produce an update to an intermediate state when there are too many
   updates.  The client recipient.  This MUST invalidate its Identity cache.

6.3.  setIdentities

   Modifying the state be one of Identity objects on the server following
         values:

         +  "unknown": The display status is done via the
   _setIdentities_ method. unknown.  This encompasses creating, updating and
   destroying Identity records.

   The _setIdentities_ method takes is the following arguments:

   o  *accountId*: "String|null"
            initial value.

         +  "yes": The id of receipient's system claims the account message content
            has been displayed to use for this
      call.  If "null", the primary account will be used.

   o  *ifInState*: "String|null" This recipient.  Note, there is a state string as returned by
      the _getIdentities_ method.  If supplied, the string must match no
            guarantee that the current state, otherwise recipient has noticed, read, or
            understood the method MUST be aborted and a
      "stateMismatch" error returned. content.

         If "null", any changes will be
      applied to the current state.

   o  *create*: "String[Identity]|null" A map of _creation id_ (an
      arbitrary string an MDN is received for this recipient with Disposition-Type
         (as per [RFC3798] section 3.2.6.2) equal to "displayed", this
         property SHOULD be set by the client) to Identity objects
      (containing all properties except the id). "yes".  The server MAY also set this
         property based on other feedback channels.

   o  *update*: "String[Identity]|null"  *dsnBlobIds*: "String[]" (server-set) A map list of id to Identity objects.
      The object may omit any property; only properties that have
      changed need be included. blob ids for DSNs
      received for this submission, in order of receipt, oldest first.

   o  *destroy*: "String[]|null"  *mdnBlobIds*: "String[]" (server-set) A list of blob ids for Identity objects to
      permanently delete.

   Each create, update or destroy is considered an atomic unit.  It is
   permissible MDNs
      received for the server to commit some this submission, in order of the changes but not
   others, however it is receipt, oldest first.

   JMAP servers MAY choose not permissible to only commit part of an
   update expose DSN and MDN responses as
   Message objects if they correlate to a single identity.

   If a create, update or destroy is rejected, the appropriate error
   MUST be added to the notCreated/notUpdated/notDestroyed property of MessageSubmission object.  It
   SHOULD only do this if it exposes them in the response _dsnBlobIds_ and
   _mdnblobIds_ fields instead, and expects the server MUST continue user to the next create/update/
   destroy.  It does not terminate the method.

   A *create* MAY be rejected with one using clients
   capable of fetching and displaying delivery status via the following errors:

   o  "maxQuotaReached": Returned if the user has reached
   MessageSubmission object.

   For efficiency, a server-
      defined limit on the number server MAY destroy MessageSubmission objects a
   certain amount of identities.

   o  "emailNotPermitted": Returned if the user tries to create an
      identity with an email address time after the user does not allow them to
      send from.

   If message is successfully sent or it
   has finished retrying sending the identity message.  For very basic SMTP
   proxies, this MAY be immediately after creation, as it has "mayDeleteIdentity == false", any attempt no way to
   destroy it MUST be rejected with
   assign a "forbidden" error.

   If an real id given cannot be found, and return the update or destroy MUST be
   rejected with a "notFound" set error. information again if fetched later.

   The response to _setIdentities_ is called _identitiesSet_. It following JMAP methods are supported:

5.1.  getMessageSubmissions

   Standard _getFoos_ method.

5.2.  getMessageSubmissionUpdates

   Standard _getFooUpdates_ method.

5.3.  getMessageSubmissionList

   Standard _getFooList_ method.

   The *FilterCondition* object (optionally passed as the _filter_
   argument) has the following arguments: properties, any of which may be omitted:

   o  *accountId*: "String"  *messageIds*: "String[]" The id of the account used for MessageSubmission _messageId_
      property must be in this list to match the call. condition.

   o  *oldState*: "String|null"  *threadIds*: "String[]" The state string that would have been
      returned by _getIdentities_ before making the requested changes,
      or "null" if the server doesn't know what MessageSubmission _threadId_ property
      must be in this list to match the previous state
      string was. condition.

   o  *newState*:  *undoStatus*: "String" The state string that will now MessageSubmission _undoStatus_ property
      must be returned by
      _getIdentities_.

   o  *created*: "String[Identity]" A map of identical to the creation id value given to an
      object containing match the *id* property for all successfully created
      identities. condition.

   o  *updated*: "String[Identity|null]"  *before*: "Date" The _keys_ in this map are the
      ids _sendAt_ property of all identities that were successfully updated.  If the
      server made any other changes to the record beyond those
      explicitly requested by the client, the _value_ for the
      corresponding id in the map is an MessageSubmission
      object containing the updated
      value of each property the *server changed*. Otherwise (if no
      properties changed on the server other than those explicitly
      updated by the client), must be before this date to match the value is "null".

   o  *destroyed*: "String[]" A list of ids for identities that were
      successfully destroyed. condition.

   o  *notCreated*: "String[SetError]" A map of creation id to a
      SetError object for each identity that failed to be created.  *after*: "Date" The
      possible errors are defined in the description _sendAt_ property of the method for
      specific data types.

   o  *notUpdated*: "String[SetError]" A map of Identity id to a
      SetError MessageSubmission
      object for each identity that failed to be updated.  The
      possible errors are defined in must be after this date to match the description condition.

   A MessageSubmission object matches the filter if and only if all of
   the method given conditions given match.  If zero properties are specified,
   it is automatically "true" for
      specific data types. all objects.

   The following properties MUST be supported for sorting:

   o  *notDestroyed*: "String[SetError]"  "messageId"

   o  "threadId"

   o  "sentAt"

5.4.  getMessageSubmissionListUpdates

   Standard _getFooListUpdates_ method.

5.5.  setMessageSubmissions

   Standard _setFoos_ method, with the following two extra arguments:

   o  *onSuccessUpdateMessage*: "String[Message]|null" A map of Identity id
      _MessageSubmission id_ to a
      SetError an object for each identity that failed containing properties to be destroyed.
      The possible errors are defined in the description of
      update on the method
      for specific data types.

   A *SetError* Message object has referenced by the following properties:

   o  *type*: "String" The type of error.

   o  *description*: "String|null" A description of MessageSubmission
      if the error create/update/destroy succeeds.  (For references to display
      MessageSubmission creations, this is equivalent to a back
      reference so the user.

   The following errors may id will be returned instead the creation id prefixed with a "#".)

   o  *onSuccessDestroyMessage*: "String[]|null" A list of
      _MessageSubmission ids_ for which the _identitiesSet_
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included message with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned
      corresponding messageId should be destroyed if the _accountId_ given
   corresponds create/update/
      destroy succeeds.  (For references to MessageSubmission creations,
      this is equivalent to a valid account, but back reference so the account does not support this
   data type.

   "accountReadOnly": Returned if id will be the account has MailCapabilities
      creation id prefixed with
   "isReadOnly == true".

   "requestTooLarge": Returned if the total number of objects a "#".)

   A single implicit _setMessages_ call MUST be made after all
   MessageSubmission create/update/destroy requests have been processed
   to create,
   update or destroy exceeds perform any changes requested in these two arguments.  The
   _messagesSet_ response MUST be returned after the maximum number
   _messageSubmissionsSet_ response.

   A message is sent by creating a MessageSubmission object.  When
   processing each create, the server must check that the message is willing
   valid, and the user has sufficient authorization to
   process in a single method call.

   "invalidArguments": Returned if one of send it.  If the arguments is of
   creation succeeds, the wrong
   type, or otherwise invalid.  A _description_ property MAY message will be sent to the recipients given
   in the envelope _rcptTo_ parameter.  The server MUST remove any _Bcc_
   header present on the response object to help debug message during delivery.  The server MAY add or
   remove other headers from the submitted message, or make further
   alterations in accordance with an explanation the server's policy during delivery.

   If the referenced message is destroyed at any point after the
   MessageSubmission object is created, this MUST NOT change the
   behaviour of what the
   problem was.

   "stateMismatch": Returned if an _ifInState_ argument was supplied and message submission (i.e. it does not match the current state.

7.  SearchSnippets

   When doing cancel a search on future
   send).

   Similarly, destroying a "String" property, MessageSubmission object MUST NOT affect the client may wish to
   show
   deliveries it represents.  It purely removes the relevant section record of the body that matches the search as
   message submission.  The server MAY automatically destroy
   MessageSubmission objects after a
   preview instead of the beginning of the message, and to highlight any
   matching terms certain time or in both this response to
   other triggers, and MAY forbid the subject of the message.  Search
   snippets represent this data.

   A *SearchSnippet* object has the client from manually destroying
   MessageSubmission objects.

   The following properties: extra _SetError_ types are defined:

   For *create*:

   o  *messageId*: "String"  "tooLarge" - The message id size is larger than the snippet applies to. server supports.
      A _maxSize_ "Number" property MUST be present on the SetError
      specifying the maximum size of a message that may be sent, in
      bytes.

   o  *subject*: "String|null" If text from  "tooManyRecipients" - The envelope (supplied or generated) has
      more recipients than the filter matches server allows.  A _maxRecipients_
      "Number" property MUST be present on the
      subject, this is SetError specifying the subject
      maximum number of the message HTML-escaped, with
      matching words/phrases wrapped in "<mark></mark>" tags.  If it allowed recipients.

   o  "noRecipients" - The envelope (supplied or generated) does not match, this is "null".
      have any rcptTo emails.

   o  *preview*: "String|null" If text from the filter matches  "invalidRecipients" - The _rcptTo_ property of the
      plain-text envelope
      (supplied or HTML body, this generated) contains at least one rcptTo value which
      is not a valid email for sending to.  An _invalidEmails_
      "String[]" property MUST be present on the relevant section SetError, which is a
      list of the body
      (converted to plain text if originally HTML), HTML-escaped, with
      matching words/phrases wrapped in "<mark></mark>" tags, up to 256
      characters long.  If it invalid emails.

   o  "notPermittedFrom" - The server does not match, this is "null".

   It is server-defined what is permit the user to send a relevant section
      message with the From header of the body message to be sent.

   o  "notPermittedToSend" - The user does not have permission to send
      at all right now for
   preview.  If some reason.  A _description_ "String"
      property MAY be present on the server is unable SetError object to display to determine search snippets, it
   MUST return "null" for both the _subject_ and _preview_ properties.

   Note, unlike most data types,
      user why they are not permitted.

   o  "messageNotFound" - The _messageId_ is not a SearchSnippet DOES NOT have valid id for a
      message in the account.

   o  "invalidMessage" - The message to be sent is invalid in some way.
      The SetError SHOULD contain a property called "id".

7.1.  getSearchSnippets

   To fetch search snippets, make _properties_ of type
      "String[]" that lists *all* the properties of the Message that
      were invalid.

   For *update*:

   o  "cannotUnsend": The client attempted to update the _undoStatus_ of
      a call valid MessageSubmission object from "pending" to "canceled", but
      the message cannot be unsent.

   For *destroy*:

   o  "forbidden": The server does not allow clients to "getSearchSnippets". destroy
      MessageSubmission objects.

6.  Identities

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

   o  *accountId*: "String|null"  *id*: "String" (immutable; server-set) The id of the account to identity.

   o  *name*: "String" (default: """") The "From" _name_ the client
      SHOULD use for when creating a new message from this
      call.  If "null", defaults to the primary account. identity.

   o  *messageIds*: "String[]"  *email*: "String" The list of ids "From" email address the client MUST use
      when creating a new message from this identity.  This property is
      immutable.  The "email" property MAY alternatively be of messages to fetch the
      snippets for. form
      "*@example.com", in which case the client may use any valid email
      address ending in "@example.com".

   o  *filter*: "FilterCondition|FilterOperator|null"  *replyTo*: "Emailer[]|null" (default: "null") The same filter as
      passed to getMessageList; see Reply-To value
      the description of client SHOULD set when creating a new message from this method for
      details.
      identity.

   o  *bcc*: "Emailer[]|null" (default: "null") The response to "getSearchSnippets" is called "searchSnippets".  It
   has Bcc value the following arguments: client
      SHOULD set when creating a new message from this identity.

   o  *accountId*:  *textSignature*: "String" The id of (default: """") Signature the account used for client
      SHOULD insert into new rich-text messages that will be sending
      from this identity.  Clients MAY ignore this and/or combine this
      with a client-specific signature preference.

   o  *htmlSignature*: "String" (default: """") Signature the call. client
      SHOULD insert into new HTML messages that will be sending from
      this identity.  This text MUST be an HTML snippet to be inserted
      into the "<body></body>" section of the new email.  Clients MAY
      ignore this and/or combine this with a client-specific signature
      preference.

   o  *filter*: "FilterCondition|FilterOperator|null" Echoed back from  *mayDelete*: "Boolean" (server-set) Is the call.

   o  *list*: "SearchSnippet[]" An array of SearchSnippet objects user allowed to delete
      this identity?  Servers may wish to set this to "false" for the requested message ids.  This may not be in
      user's username or other default address.

   Multiple identities with the same order as
      the ids that were in email address MAY exist, to allow
   for different settings the request.

   o  *notFound*: "String[]|null" An array of message ids requested
      which could not user wants to pick between (for example
   with different names/signatures).

   The following JMAP methods are supported:

6.1.  getIdentities

   Standard _getFoos_ method.  The _ids_ argument may be found, or "null" if to fetch
   all ids were found.

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

6.2.  getIdentityUpdates

   Standard _getFooUpdates_ method.

6.3.  setIdentities

   Standard _setFoos_ method.  The following errors may be returned instead of the _searchSnippets_
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with extra _SetError_ types are
   defined:

   For *create*:

   o  "maxQuotaReached": The user has reached a server-defined limit on
      the request, but it does number of identities.

   o  "emailNotPermitted": The user is not correspond alloed to a valid account.

   "accountNotSupportedByMethod": Returned if send from the _accountId_
      address given
   corresponds to a valid account, but the account does not support this
   data type.

   "requestTooLarge": Returned if as the number _email_ property of _messageIds_ requested
   by the client exceeds the maximum number the server is willing to
   process in a single method call.

   "cannotDoFilter": identity.

   For *destroy*:

   o  "forbidden": Returned if the server identity's _mayDelete_ value is unable to process the
   given _filter_ for any reason.

   "invalidArguments": Returned if
      "false".

7.  SearchSnippets

   When doing a search on a "String" property, the request does not include one of client may wish to
   show the required arguments, or one relevant section of the arguments is body that matches the search as a
   preview instead of the wrong type,
   or otherwise invalid.  A "description" property MAY be present on beginning of the
   response object message, and to help debug with an explanation highlight any
   matching terms in both this and the subject of what the problem
   was.

8.  Vacation Response

   The *VacationResponse* message.  Search
   snippets represent this data.

   A *SearchSnippet* object represents the state of vacation-
   response related settings for an account.  It has the following properties:

   o  *id*:  *messageId*: "String" The id of the object.  This property is immutable.
      There is only ever one vacation response object, and its id is
      ""singleton"".

   o  *isEnabled* "Boolean" Should a vacation response be sent if a message arrives between id the _fromDate_ and _toDate_? snippet applies to.

   o  *fromDate*: "Date|null"  *subject*: "String|null" If _isEnabled_ is "true", the date/time
      after which messages that arrive should receive text from the user's
      vacation response, in UTC.  If "null", filter matches the vacation response is
      effective immediately.

   o  *toDate*: "Date|null" If _isEnabled_
      subject, this is "true", the date/time
      after which messages that arrive should no longer receive subject of the
      user's vacation response, message HTML-escaped, with
      matching words/phrases wrapped in UTC. "<mark></mark>" tags.  If "null", the vacation
      response it
      does not match, this is effective indefinitely. "null".

   o  *subject*:  *preview*: "String|null" The subject that will be used by the mail
      sent in response to messages when the vacation response is
      enabled. If null, an appropriate subject SHOULD be set by the
      server.

   o  *textBody*: "String|null" The plain text part from the filter matches the
      plain-text or HTML body, this is the relevant section of the message body
      (converted to
      send plain text if originally HTML), HTML-escaped, with
      matching words/phrases wrapped in response "<mark></mark>" tags, up to messages when the vacation response is
      enabled. 256
      characters long.  If it does not match, this is "null", when the vacation message is sent a
      plain-text body part SHOULD be generated "null".

   o  *attachments*: "String|null" If text from the _htmlBody_ but filter matches the server MAY choose to send
      text extracted from an attachment, this is the response as HTML only.

   o  *htmlBody*: "String|null" The HTML message relevant section of
      the attachment (converted to send plain text), with matching words/
      phrases wrapped in response "<mark></mark>" tags, up to
      messages when the vacation response is enabled. 256 characters
      long.  If it does not match, this is
      "null", when the vacation message "null".

   It is sent an HTML body part MAY be
      generated from server-defined what is a relevant section of the _textBody_, or body for
   preview.  If the server MAY choose is unable to send
      the response as plain-text only.

8.1.  getVacationResponse

   There MUST only be exactly one VacationResponse object in an account.
   It determine search snippets, it
   MUST have return "null" for both the id ""singleton"". _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.  getSearchSnippets

   To fetch the vacation response object, search snippets, make a call to
   "getVacationResponse". "getSearchSnippets".  It
   takes the following argument: arguments:

   o  *accountId*: "String|null" The Account to get id of the vacation
      response for. account to use for this
      call.  If "null", defaults to the primary account is used. account.

   o  *messageIds*: "String[]" The list of ids of messages to fetch the
      snippets for.

   o  *filter*: "FilterCondition|FilterOperator|null" The same filter as
      passed to getMessageList; see the description of this method for
      details.

   The response to _getVacationResponse_ "getSearchSnippets" is called _vacationResponse_. "searchSnippets".  It
   has the following arguments:

   o  *accountId*: "String" The id of the account used for the call.

   o  *filter*: "FilterCondition|FilterOperator|null" Echoed back from
      the call.

   o  *list*: "VacationResponse[]" "SearchSnippet[]" An array containing of SearchSnippet objects for
      the single
      VacationResponse object. requested message ids.  This may not be in the same order as
      the ids that were in the request.

   o  *notFound*: "String[]|null" An array of message ids requested
      which could not be found, or "null" if all ids were found.

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

   The following errors may be returned instead of the
   _vacationResponse_ _searchSnippets_
   response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with the request, but it does not correspond to a valid account.

   "accountNotSupportedByMethod": Returned if the _accountId_ given
   corresponds to a valid account, but the account does not support this
   data type.

8.2.  setVacationResponse

   Sets properties on

   "requestTooLarge": Returned if the vacation response object.  It takes number of _messageIds_ requested
   by the
   following arguments:

   o  *accountId*: "String|null" The Account to set client exceeds the vacation
      response for.  If "null", maximum number the primary account server is used.

   o  *update*: "String[VacationResponse]|null" A map of id
      ("singleton") to the VacationResponse object with new values for
      the properties you wish willing to change.  The object may omit any
      property; only properties that have changed need be included.

   If any of the properties
   process in a single method call.

   "cannotDoFilter": Returned if the update are invalid (immutable and
   different server is unable to process the current server value, wrong type),
   given _filter_ for any reason.

   "invalidArguments": Returned if the server MUST
   reject request does not include one of
   the update with a SetError required arguments, or one of type "invalidProperties".  The
   SetError object SHOULD contain a property called _properties_ the arguments is of type
   "String[]" that lists *all* the properties that were wrong type,
   or otherwise invalid.  The
   object MAY also contain a _description_  A "description" property of type "String" MAY be present on the
   response object to help debug with a user-friendly description an explanation of what the problems. problem
   was.

8.  Vacation Response

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

   o  *updated*: "String[]"  *id*: "String" (immutable) The id of the object.  There is only
      ever one vacation response object, and its id is ""singleton"".

   o  *updated*: "String[VacationResponse|null]" If successfully
      updated, this map will have  *isEnabled* "Boolean" Should a sole key of "singleton".  The
      _value_ in vacation response be sent if a
      message arrives between the map _fromDate_ and _toDate_?

   o  *fromDate*: "Date|null" If _isEnabled_ is an object containing "true", the updated value of
      each property date/time
      after which messages that arrive should receive the *server changed* on user's
      vacation response, in UTC.  If "null", the record, if any.
      Otherwise (if no properties changed on vacation response is
      effective immediately.

   o  *toDate*: "Date|null" If _isEnabled_ is "true", the server other than those
      explicitly updated by date/time
      after which messages that arrive should no longer receive the client),
      user's vacation response, in UTC.  If "null", the value vacation
      response is "null". effective indefinitely.

   o  *notUpdated*: "String[SetError]" A map of id ("singleton")  *subject*: "String|null" The subject that will be used by the mail
      sent in response to a
      SetError object if messages when the update failed.

   A *SetError* object has vacation response is
      enabled.  If null, an appropriate subject SHOULD be set by the following properties:

   o  *type*: "String" The type of error.
      server.

   o  *description*:  *textBody*: "String|null" A description The plain text part of the error message to display
      send in response to messages when the user.

   The following errors may be returned instead of vacation response is
      enabled.  If this is "null", when the
   _vacationResponseSet_ response:

   "accountNotFound": Returned if an _accountId_ was explicitly included
   with vacation message is sent a
      plain-text body part SHOULD be generated from the request, but it does not correspond _htmlBody_ but
      the server MAY choose to a valid account.

   "accountNotSupportedByMethod": Returned if send the _accountId_ given
   corresponds response as HTML only.

   o  *htmlBody*: "String|null" The HTML message to a valid account, but send in response to
      messages when the account does not support vacation response is enabled.  If this
   data type.

   "invalidArguments": Returned if one of the arguments is of
      "null", when the wrong
   type, or otherwise invalid (including using vacation message is sent an id other than
   ""singleton"").  A "description" property HTML body part MAY be present on
      generated from the _textBody_, or the server MAY choose to send
      the response as plain-text only.

   The following JMAP methods are supported:

8.1.  getVacationResponse

   Standard _getFoos_ method.

   There MUST only be exactly one VacationResponse object to help debug with in an explanation of what account.
   It MUST have the problem
   was. id ""singleton"".

8.2.  setVacationResponse

   Standard _setFoos_ method.  The following extra _SetError_ types are
   defined:

   For *create* or *destroy*:

   o  "singleton": This is a singleton object, so you cannot create
      another one or destroy the existing one.

9.  Security considerations

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

10.  References

9.1.

10.1.  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,
              <https://www.rfc-editor.org/info/rfc1870>.

   [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,
              <https://www.rfc-editor.org/info/rfc2047>.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <http://www.rfc-editor.org/info/rfc2119>.
              <https://www.rfc-editor.org/info/rfc2119>.

   [RFC2852]  Newman, D., "Deliver By SMTP Service Extension", RFC 2852,
              DOI 10.17487/RFC2852, June 2000,
              <https://www.rfc-editor.org/info/rfc2852>.

   [RFC3461]  Moore, K., "Simple Mail Transfer Protocol (SMTP) Service
              Extension for Delivery Status Notifications (DSNs)",
              RFC 3461, DOI 10.17487/RFC3461, January 2003,
              <https://www.rfc-editor.org/info/rfc3461>.

   [RFC3463]  Vaudreuil, G., "Enhanced Mail System Status Codes",
              RFC 3463, DOI 10.17487/RFC3463, January 2003,
              <https://www.rfc-editor.org/info/rfc3463>.

   [RFC3464]  Moore, K. and G. Vaudreuil, "An Extensible Message Format
              for Delivery Status Notifications", RFC 3464,
              DOI 10.17487/RFC3464, January 2003,
              <https://www.rfc-editor.org/info/rfc3464>.

   [RFC3629]  Yergeau, F., "UTF-8, a transformation format of ISO
              10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November
              2003, <http://www.rfc-editor.org/info/rfc3629>. <https://www.rfc-editor.org/info/rfc3629>.

   [RFC3798]  Hansen, T., Ed. and G. Vaudreuil, Ed., "Message
              Disposition Notification", RFC 3798, DOI 10.17487/RFC3798,
              May 2004, <https://www.rfc-editor.org/info/rfc3798>.

   [RFC4648]  Josefsson, S., "The Base16, Base32, and Base64 Data
              Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006,
              <https://www.rfc-editor.org/info/rfc4648>.

   [RFC4865]  White, G. and G. Vaudreuil, "SMTP Submission Service
              Extension for Future Message Release", RFC 4865,
              DOI 10.17487/RFC4865, May 2007,
              <https://www.rfc-editor.org/info/rfc4865>.

   [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,
              <https://www.rfc-editor.org/info/rfc5248>.

   [RFC5321]  Klensin, J., "Simple Mail Transfer Protocol", RFC 5321,
              DOI 10.17487/RFC5321, October 2008,
              <https://www.rfc-editor.org/info/rfc5321>.

   [RFC5322]  Resnick, P., Ed., "Internet Message Format", RFC 5322,
              DOI 10.17487/RFC5322, October 2008,
              <http://www.rfc-editor.org/info/rfc5322>.
              <https://www.rfc-editor.org/info/rfc5322>.

   [RFC5788]  Melnikov, A. and D. Cridland, "IMAP4 Keyword Registry",
              RFC 5788, DOI 10.17487/RFC5788, March 2010,
              <http://www.rfc-editor.org/info/rfc5788>.
              <https://www.rfc-editor.org/info/rfc5788>.

   [RFC6409]  Gellens, R. and J. Klensin, "Message Submission for Mail",
              STD 72, RFC 6409, DOI 10.17487/RFC6409, November 2011,
              <https://www.rfc-editor.org/info/rfc6409>.

   [RFC6533]  Hansen, T., Ed., Newman, C., and A. Melnikov,
              "Internationalized Delivery Status and Disposition
              Notifications", RFC 6533, DOI 10.17487/RFC6533, February
              2012, <https://www.rfc-editor.org/info/rfc6533>.

   [RFC6710]  Melnikov, A. and K. Carlberg, "Simple Mail Transfer
              Protocol Extension for Message Transfer Priorities",
              RFC 6710, DOI 10.17487/RFC6710, August 2012,
              <https://www.rfc-editor.org/info/rfc6710>.

   [RFC7159]  Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
              Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March
              2014, <http://www.rfc-editor.org/info/rfc7159>.

9.2. <https://www.rfc-editor.org/info/rfc7159>.

   [RFC7493]  Bray, T., Ed., "The I-JSON Message Format", RFC 7493,
              DOI 10.17487/RFC7493, March 2015,
              <https://www.rfc-editor.org/info/rfc7493>.

10.2.  URIs

   [1] server.html

   [2] https://tools.ietf.org/html/rfc4648

   [3] http://tools.ietf.org/html/rfc2047

   [4] https://www.iana.org/assignments/imap-keywords/imap-
       keywords.xhtml

Author's Address

   Neil Jenkins
   FastMail
   Level 1, 91 2, 114 William St
   Melbourne  VIC 3000
   Australia

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