<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' []>
<rfc ipr="trust200902" category="std" docName="draft-ietf-jmap-mdn-14">
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc private=""?>
<?rfc topblock="yes"?>
<?rfc comments="no"?>
<front>
<title abbrev="JMAP MDN handling">Handling Message Disposition Notification with JMAP</title>

<author role="editor" initials="R.O." surname="Ouazana" fullname="Raphaël Ouazana">
<organization>Linagora</organization>
<address>
<postal>
<street>100 Terrasse Boieldieu – Tour Franklin</street>
<city>Paris - La Défense CEDEX</city>
<code>92042</code>
<country>France</country>
<region></region>
</postal>
<phone></phone>
<email>rouazana@linagora.com</email>
<uri>https://www.linagora.com</uri>
</address>
</author>
<date year="2020" month="July" day="24"/>

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


<abstract>
<t>This document specifies a data model for handling Message Disposition Notifications (MDNs, RFC 8098) in the JSON Meta Application Protocol (JMAP, RFCs 8620 and 8621).
</t>
</abstract>


</front>

<middle>

<section anchor="introduction" title="Introduction">
<t>JMAP (<xref target="RFC8620"/> – JSON Meta Application Protocol) 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 provides a consistent interface to different data types.
</t>
<t>JMAP for Mail (<xref target="RFC8621"/> - The JSON Meta Application Protocol (JMAP) for Mail) specifies a data model for synchronising email data with a server using JMAP. Clients can use this to efficiently search, access, organise, and send messages.
</t>
<t>Message Disposition Notifications (MDNs) are defined in <xref target="RFC8098"/> and are used as &quot;read receipts&quot;, &quot;acknowledgements&quot;, or &quot;receipt notifications&quot;.
</t>
<t>A client can have to deal with MDNs in different ways:
</t>
<t>
<list style="numbers">
<t>When receiving an email message, an MDN can be sent to the sender. This specification defines an MDN/send method to cover this case.</t>
<t>When sending an email message, an MDN can be requested. This must be done with the help of a header, and is already specified by <xref target="RFC8098"/> and can already be handled by <xref target="RFC8621"/> this way.</t>
<t>When receiving an MDN, the MDN could be related to an existing sent message. This is already covered by <xref target="RFC8621"/> in the EmailSubmission object. A client might want to display detailed information about a received MDN. This specification defines an MDN/parse method to cover this case.</t>
</list>
</t>

<section anchor="notational-conventions" title="Notational conventions">
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL NOT&quot;, &quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;, &quot;MAY&quot;, and &quot;OPTIONAL&quot; in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.
</t>
<t>Type signatures, examples and property descriptions in this document follow the conventions established in section 1.1 of <xref target="RFC8620"/>. Data types defined in the core specification are also used in this document.
</t>
<t>Servers MUST support all properties specified for the new data types defined in this document.
</t>
</section>

<section anchor="terminology" title="Terminology">
<t>The same terminology is used in this document as in the core JMAP specification.
</t>
<t>Because keywords are case-insensitive in IMAP but case-sensitive in JMAP, the &quot;$mdnsent&quot; keyword MUST always be used in lowercase.
</t>
</section>

<section anchor="addition-to-the-capabilities-object" title="Addition to the capabilities object">
<t>Capabilities are announced as part of the standard JMAP Session resource; see <xref target="RFC8620"/>, section 2. This defines a new capability, &quot;urn:ietf:params:jmap:mdn&quot;.
</t>
<t>The capability &quot;urn:ietf:params:jmap:mdn&quot; being present in the &quot;accountCapabilities&quot; property of an account represents support for the &quot;MDN&quot; data type, parsing MDNs via the &quot;MDN/parse&quot; method, and creating and sending MDN messages via the &quot;MDN/send&quot; method.
Servers that include the capability in one or more &quot;accountCapabilities&quot; properties MUST also include the property in the &quot;capabilities&quot; property.
</t>
<t>The value of this &quot;urn:ietf:params:jmap:mdn&quot; property is an empty object in the account's &quot;accountCapabilities&quot; property.
</t>
</section>
</section>

<section anchor="mdn" title="MDN">
<t>An <spanx style="strong">MDN</spanx> object has the following properties:
</t>
<t>
<list style="symbols">
<t>forEmailId: <spanx style="verb">Id|null</spanx>
Email Id of the received message this MDN is relative to. This property MUST NOT be null for &quot;MDN/send&quot;, but may be null in the response from the &quot;MDN/parse&quot; method.</t>
<t>subject: <spanx style="verb">String|null</spanx>
Subject used as <spanx style="verb">Subject</spanx> header for this MDN.</t>
<t>textBody: <spanx style="verb">String|null</spanx>
Human readable part of the MDN, as plain text.</t>
<t>includeOriginalMessage: <spanx style="verb">Boolean</spanx> (default: false). If <spanx style="verb">true</spanx>, the content of the original message will appear in the third component of the multipart/report generated for the MDN. See <xref target="RFC8098"/> for details and security considerations.</t>
<t>reportingUA: <spanx style="verb">String|null</spanx>
Name of the MUA creating this MDN. It is used to build the MDN Report part of the MDN.</t>
<t>disposition: <spanx style="verb">Disposition</spanx>
Object containing the diverse MDN disposition options.</t>
<t>mdnGateway: <spanx style="verb">String|null</spanx> (server-set)
Name of the gateway or MTA that translated a foreign (non-Internet) message disposition notification into this MDN.</t>
<t>originalRecipient: <spanx style="verb">String|null</spanx> (server-set)
Original recipient address as specified by the sender of the message for which the MDN is being issued.</t>
<t>finalRecipient: <spanx style="verb">String|null</spanx>
Recipient for which the MDN is being issued.  if set, it overrides the value that would be calculated by the server from the Identity.</t>
<t>originalMessageId: <spanx style="verb">String|null</spanx> (server-set)
Message-ID (the <xref target="RFC5322"/> header field, not the JMAP Id) of the message for which the MDN is being issued.</t>
<t>error: <spanx style="verb">String[]|null</spanx> (server-set)
Additional information in the form of text messages when the &quot;error&quot; disposition modifier appears.</t>
<t>extensionFields: <spanx style="verb">String[String]|null</spanx>
Object where keys are extension-field names and values are extension-field values.</t>
</list>
</t>
<t>A <spanx style="strong">Disposition</spanx> object has the following properties:
</t>
<t>
<list style="symbols">
<t>actionMode: <spanx style="verb">String</spanx>
This MUST be one of the following strings: &quot;manual-action&quot; / &quot;automatic-action&quot;</t>
<t>sendingMode: <spanx style="verb">String</spanx>
This MUST be one of the following strings: &quot;mdn-sent-manually&quot; / &quot;mdn-sent-automatically&quot;</t>
<t>type: <spanx style="verb">String</spanx>
This MUST be one of the following strings: &quot;deleted&quot; / &quot;dispatched&quot; / &quot;displayed&quot; / &quot;processed&quot;</t>
</list>
</t>
<t>See <xref target="RFC8098"/> for the exact meaning of these different fields. These fields are defined case insensitive in <xref target="RFC8098"/> but are case sensitive in this RFC and MUST be converted to lowercase by &quot;MDN/parse&quot;.
</t>

<section anchor="mdnsend" title="MDN/send">
<t>The MDN/send method sends an <xref target="RFC5322"/> message from an MDN object. When calling this method the &quot;using&quot; property of the Request object MUST contain the capabilities &quot;urn:ietf:params:jmap:mdn&quot; and &quot;urn:ietf:params:jmap:mail&quot;. The latter because of the implicit call to Email/set and the use of Identities, described below.
The method takes the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx>
The id of the account to use.</t>
<t>identityId: <spanx style="verb">Id</spanx>
The id of the Identity to associate with these MDNs. The server will use this identity to define the sender of the MDNs and to set the finalRecipient field.</t>
<t>send: <spanx style="verb">Id[MDN]</spanx>
A map of creation id (client specified) to MDN objects.</t>
<t>onSuccessUpdateEmail: <spanx style="verb">Id[PatchObject]|null</spanx>
A map of id to an object containing properties to update on the Email object referenced by the &quot;MDN/send&quot; if the sending succeeds. This will always be a backward reference to the creation id (see example below in Section 3.1).</t>
</list>
</t>
<t>The response has the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx>
The id of the account used for the call.</t>
<t>sent: <spanx style="verb">Id[MDN]|null</spanx>
A map of creation id to MDN containing any properties that were not set by the client. This includes any properties that were omitted by the client and thus set to a default by the server. This argument is null if no MDN objects were successfully sent.</t>
<t>notSent: <spanx style="verb">Id[SetError]|null</spanx>
A map of the creation id to a SetError object for each record that failed to be sent, or null if all successful.</t>
</list>
</t>
<t>The following already registered SetError would mean:
</t>
<t>
<list style="symbols">
<t>notFound: The reference Email Id cannot be found, or has no valid &quot;Disposition-Notification-To&quot; header.</t>
<t>forbidden: MDN/send would violate an ACL or other permissions policy.</t>
<t>forbiddenFrom: The user is not allowed to use the given finalRecipient property.</t>
<t>overQuota: MDN/send would exceed a server-defined limit on the number or total size of sent MDNs. It could include limitations on sent messages.</t>
<t>tooLarge: MDN/send would result in an MDN that exceeds a server-defined limit for the maximum size of an MDN, or more generally on email message.</t>
<t>rateLimit: Too many MDNs or email messages have been created recently, and a server-defined rate limit has been reached. It may work if tried again later.</t>
<t>invalidProperties: The record given is invalid in some way.</t>
</list>
</t>
<t>The following is a new SetError:
</t>
<t>
<list style="symbols">
<t>mdnAlreadySent: The message has the <spanx style="verb">$mdnsent</spanx> keyword already set.</t>
</list>
</t>
<t>If the accountId or identityId given cannot be found, the method call is rejected with an <spanx style="verb">invalidArguments</spanx> error.
</t>
<t>The client SHOULD NOT issue an MDN/send request if the message has the <spanx style="verb">$mdnsent</spanx> keyword set.
</t>
<t>When sending the MDN, the server is in charge of generating the &quot;originalRecipient&quot;, &quot;finalRecipient&quot; and &quot;originalMessageId&quot; fields according to the <xref target="RFC8098"/> specification.
</t>
<t>The client is expected to explicitly update each &quot;Email&quot; for which an &quot;MDN/send&quot; has been invoked in order to set the &quot;$mdnsent&quot; keyword on these messages. To ensure that, the server MUST reject an &quot;MDN/send&quot; which does not result in setting the keyword &quot;$mdnsent&quot;. Thus the server MUST check that the &quot;onSuccessUpdateEmail&quot; property of the method is correctly set to update this keyword.
</t>
</section>

<section anchor="mdnparse" title="MDN/parse">
<t>This method allows a client to parse blobs as <xref target="RFC5322"/> messages to get MDN objects. This can be used to parse and get detailed information about blobs referenced in the &quot;mdnBlobIds&quot; of the EmailSubmission object, or any email message the client could expect to be an MDN.
</t>
<t>The &quot;forEmailId&quot; property can be null or missing if the &quot;originalMessageId&quot; property is missing or does not refer to an existing message, or if the server cannot efficiently calculate the related message (for example, if several messages get the same &quot;Message-Id&quot; header).
</t>
<t>The MDN/parse method takes the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx>
The id of the account to use.</t>
<t>blobIds: <spanx style="verb">Id[]</spanx>
The ids of the blobs to parse.</t>
</list>
</t>
<t>The response has the following arguments:
</t>
<t>
<list style="symbols">
<t>accountId: <spanx style="verb">Id</spanx>
The id of the account used for the call.</t>
<t>parsed: <spanx style="verb">Id[MDN]|null</spanx>
A map of blob id to parsed MDN representation for each successfully parsed blob, or null if none.</t>
<t>notParsable: <spanx style="verb">Id[]|null</spanx>
A list of ids given that corresponded to blobs that could not be parsed as MDNs, or null if none.</t>
<t>notFound: <spanx style="verb">Id[]|null</spanx>
A list of blob ids given that could not be found, or null if none.</t>
</list>
</t>
<t>The following additional errors may be returned instead of the MDN/parse response:
</t>
<t>
<list style="symbols">
<t>requestTooLarge: The number of ids requested by the client exceeds the maximum number the server is willing to process in a single method call.</t>
<t>invalidArguments: If the accountId given cannot be found, the MDN parsing is rejected with an <spanx style="verb">invalidArguments</spanx> error.</t>
</list>
</t>
</section>
</section>

<section anchor="samples" title="Samples">

<section anchor="sending-an-mdn-for-a-received-email-message" title="Sending an MDN for a received email message">
<t>A client can use the following request to send an MDN back to the sender:
</t>

<figure align="center"><artwork align="center">
[[ "MDN/send", {
  "accountId": "ue150411c",
  "identityId": "I64588216",
  "send": {
    "k1546": {
      "forEmailId": "Md45b47b4877521042cec0938",
      "subject": "Read receipt for: World domination",
      "textBody": "This receipt shows that the email has been 
          displayed on your recipient's computer. There is no 
          guaranty it has been read or understood.",
      "reportingUA": "joes-pc.cs.example.com; Foomail 97.1",
      "disposition": {
        "actionMode": "manual-action",
        "sendingMode": "mdn-sent-manually",
        "type": "displayed"
      },
      "extension": {
        "X-EXTENSION-EXAMPLE": "example.com"
      }
    }
  },
  "onSuccessUpdateEmail": {
    "#k1546": {
      "keywords/$mdnsent": true
    }
  }
}, "0" ]]
</artwork></figure>
<t>If the email id matches an existing email message without the <spanx style="verb">$mdnsent</spanx> keyword, the server can answer:
</t>

<figure align="center"><artwork align="center">
[[ "MDN/send", {
  "accountId": "ue150411c",
  "sent": {
    "k1546": {
      "finalRecipient": "rfc822; john@example.com",
      "originalMessageId": "&lt;199509192301.23456@example.org&gt;"
    }
  }
}, "0" ],
[ "Email/set", {
  "accountId": "ue150411c",
  "oldState": "23",
  "newState": "42",
  "updated": {
    "Md45b47b4877521042cec0938": {}
  }
}, "0" ]]
</artwork></figure>
<t>If the <spanx style="verb">$mdnsent</spanx> keyword has already been set, the server can answer an error:
</t>

<figure align="center"><artwork align="center">
[[ "MDN/send", {
  "accountId": "ue150411c",
  "notSent": {
    "k1546": {
      "type": "mdnAlreadySent",
      "description" : "$mdnsent keyword is already present"
    }
  }
}, "0" ]]
</artwork></figure>
</section>

<section anchor="asking-for-mdn-when-sending-an-email-message" title="Asking for MDN when sending an email message">
<t>This is done with the <xref target="RFC8621"/> &quot;Email/set&quot; &quot;create&quot; method.
</t>

<figure align="center"><artwork align="center">
[[ "Email/set", {
  "accountId": "ue150411c",
  "create": {
    "k1546": {
      "mailboxIds": {
        "2ea1ca41b38e": true
      },
      "keywords": {
        "$seen": true,
        "$draft": true
      },
      "from": [{
        "name": "Joe Bloggs",
        "email": "joe@example.com"
      }],
      "to": [{
        "name": "John",
        "email": "john@example.com"
      }],
      "header:Disposition-Notification-To:asText": "joe@example.com",
      "subject": "World domination",
      ...
    }
  }
}, "0" ]]
</artwork></figure>
<t>Note the specified <spanx style="verb">Disposition-Notification-To</spanx> header indicating where to send MDN back (usually the sender of the message).
</t>
</section>

<section anchor="parsing-a-received-mdn" title="Parsing a received MDN">
<t>The client issues a parse request:
</t>

<figure align="center"><artwork align="center">
[[ "MDN/parse", {
  "accountId": "ue150411c",
  "blobIds": [ "0f9f65ab-dc7b-4146-850f-6e4881093965" ]
}, "0" ]]
</artwork></figure>
<t>The server responds:
</t>

<figure align="center"><artwork align="center">
[[ "MDN/parse", {
  "accountId": "ue150411c",
  "parsed": {
    "0f9f65ab-dc7b-4146-850f-6e4881093965": {
      "forEmailId": "Md45b47b4877521042cec0938",
      "subject": "Read receipt for: World domination",
      "textBody": "This receipt shows that the email has been 
          displayed on your recipient's computer. There is no 
          guaranty it has been read or understood.",
      "reportingUA": "joes-pc.cs.example.com; Foomail 97.1",
      "disposition": {
        "actionMode": "manual-action",
        "sendingMode": "mdn-sent-manually",
        "type": "displayed"
      },
      "finalRecipient": "rfc822; john@example.com",
      "originalMessageId": "&lt;199509192301.23456@example.org&gt;"
    }
  }
}, "0" ]]
</artwork></figure>
<t>In case of a not found blobId, the server would respond:
</t>

<figure align="center"><artwork align="center">
[[ "MDN/parse", {
  "accountId": "ue150411c",
  "notFound": [ "0f9f65ab-dc7b-4146-850f-6e4881093965" ]
}, "0" ]]
</artwork></figure>
<t>If the blobId has been found but is not parsable, the server would respond:
</t>

<figure align="center"><artwork align="center">
[[ "MDN/parse", {
  "accountId": "ue150411c",
  "notParsable": [ "0f9f65ab-dc7b-4146-850f-6e4881093965" ]
}, "0" ]]
</artwork></figure>
</section>
</section>

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

<section anchor="jmap-capability-registration-for-mdn" title="JMAP Capability Registration for &quot;mdn&quot;">
<t>IANA will register the &quot;mdn&quot; JMAP Capability as follows:
</t>
<t>Capability Name: <spanx style="verb">urn:ietf:params:jmap:mdn</spanx>
</t>
<t>Specification document: this document
</t>
<t>Intended use: common
</t>
<t>Change Controller: IETF
</t>
<t>Security and privacy considerations: this document, section 5.
</t>
</section>

<section anchor="jmap-error-codes-registry" title="JMAP Error Codes Registry">
<t>This section registers one new error code in the &quot;JMAP Error Codes&quot; registry, as defined in <xref target="RFC8620"/>.
</t>
<t>JMAP Error Code: mdnAlreadySent
</t>
<t>Intended use: common
</t>
<t>Change controller: IETF
</t>
<t>Reference: This document, Section 2.1
</t>
<t>Description: The message has the <spanx style="verb">$mdnsent</spanx> keyword already set. The client MUST NOT try again to send an MDN for this message.
</t>
</section>
</section>

<section anchor="security-considerations" title="Security considerations">
<t>The same considerations regarding MDN (see <xref target="RFC8098"/> and <xref target="RFC3503"/>) apply to this document.
</t>
<t>In order to enforce trust regarding the relation between the user sending an email message and the identity of this user, the server SHOULD validate in conformance to the provided Identity that the user is permitted to use the finalRecipient value and return a forbiddenFrom error if not.
</t>
</section>

</middle>
<back>
<references title="Normative References">
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.3503.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5322.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8098.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8620.xml"?>
<?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8621.xml"?>
</references>

</back>
</rfc>
