Skip to content

Conversation

sherlockvn
Copy link
Collaborator

@sherlockvn sherlockvn commented Oct 4, 2022

Copy link
Member

@dab246 dab246 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use MDN/send

Header

Accept: application/json; charset=UTF-8; jmapVersion=rfc-8621

Request

{
    "using": [
        "urn:ietf:params:jmap:mail",
        "urn:ietf:params:jmap:mdn",
        "urn:ietf:params:jmap:core"
    ],
    "methodCalls": [
        [
            "MDN/send",
            {
                "accountId": "{{accountId}}",
                "identityId": "{{identityId}}",
                "send": {
                    "k1546": {
                        "forEmailId": "31ed5fe0-4486-11ed-b412-4700d9090322",
                        "subject": "Subject MDN/send",
                        "textBody": "Hello MDN/send",
                        "disposition": {
                            "actionMode": "manual-action",
                            "sendingMode": "mdn-sent-manually",
                            "type": "displayed"
                        }
                    }
                },
                "onSuccessUpdateEmail": {
                    "#k1546": {
                        "keywords/$mdnsent": true
                    }
                }
            },
            "0"
        ]
    ]
}

Response

  • If the email id matches an existing email message without the $mdnsent keyword, the server can answer:
{
    "sessionState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
    "methodResponses": [
        [
            "MDN/send",
            {
                "accountId": "0d14dbabe6482aff5cbf922e04cef51a40b4eabccbe12d28fe27c97038752555",
                "sent": {
                    "k1546": {
                        "originalRecipient": "rfc822; [email protected]",
                        "finalRecipient": "rfc822; [email protected]",
                        "includeOriginalMessage": false
                    }
                }
            },
            "0"
        ],
        [
            "Email/set",
            {
                "accountId": "0d14dbabe6482aff5cbf922e04cef51a40b4eabccbe12d28fe27c97038752555",
                "oldState": "324b8570-4486-11ed-b412-4700d9090322",
                "newState": "324b8570-4486-11ed-b412-4700d9090322",
                "updated": {
                    "31ed5fe0-4486-11ed-b412-4700d9090322": null
                }
            },
            "0"
        ]
    ]
}
  • If the $mdnsent keyword has already been set, the server can answer an error:
{
    "sessionState": "2c9f1b12-b35a-43e6-9af2-0106fb53a943",
    "methodResponses": [
        [
            "MDN/send",
            {
                "accountId": "0d14dbabe6482aff5cbf922e04cef51a40b4eabccbe12d28fe27c97038752555",
                "sent": {
                    "k1546": {
                        "originalRecipient": "rfc822; [email protected]",
                        "finalRecipient": "rfc822; [email protected]",
                        "includeOriginalMessage": false
                    }
                }
            },
            "0"
        ],
        [
            "Email/set",
            {
                "accountId": "0d14dbabe6482aff5cbf922e04cef51a40b4eabccbe12d28fe27c97038752555",
                "oldState": "324b8570-4486-11ed-b412-4700d9090322",
                "newState": "324b8570-4486-11ed-b412-4700d9090322",
                "updated": {
                    "31ed5fe0-4486-11ed-b412-4700d9090322": null
                }
            },
            "0"
        ]
    ]
}

@sherlockvn sherlockvn force-pushed the feature/add-mdn-send-parse branch from 125e612 to 8ab5958 Compare October 6, 2022 02:38
@hoangdat
Copy link
Member

hoangdat commented Oct 6, 2022

still not have test

@dab246
Copy link
Member

dab246 commented Oct 6, 2022

To get forEmailId passed in MDN/send can be done in 2 ways:

  1. Send an email with a header attribute in the outgoing email:
    "header:Disposition-Notification-To:asText": "{{username}}"
  • Request sent
"Email/set",
            {
                "accountId": "{{accountId}}",
                "create": {
                    "e01": {
                        "mailboxIds": {
                            "9bc32a50-32cf-11eb-995c-a3ae66e9f96a": true
                        },
                        "subject": "[POSTMAN] SEND EMAIL WITH MDN",
                        "from": [
                            {
                                "name": "{{username}}",
                                "email": "{{username}}"
                            }
                        ],
                        "big": [
                            {
                                "name": "firstname239.surname239",
                                "email": "[email protected]"
                            }
                        ],
                        "htmlBody": [
                            {
                                "partId": "abc123",
                                "type": "text/html"
                            }
                        ],
                        "bodyValues": {
                            "abc123": {
                                "value": "[POSTMAN] SEND EMAIL WITH MDN",
                                "isEncodingProblem": false,
                                "isTruncated": false
                            }
                        },
                        "header:Disposition-Notification-To:asText": "{{username}}"
                    }
                }
            },
  • Then get the id value in created of the Email/set method of the returned response.
"Email/set",
            {
                "accountId": "0d14dbabe6482aff5cbf922e04cef51a40b4eabccbe12d28fe27c97038752555",
                "oldState": "1bce8420-4551-11ed-a5ca-053c64f285c3",
                "newState": "1bce8420-4551-11ed-a5ca-053c64f285c3",
                "created": {
                    "e01": {
                        "id": "4cb8a430-4551-11ed-96d7-838c1117bed5",
                        "blobId": "4cb8a430-4551-11ed-96d7-838c1117bed5",
                        "threadId": "4cb8a430-4551-11ed-96d7-838c1117bed5",
                        "size": 1011
                    }
                }
            },
            "c1"
  1. Use MDN/parse to get forEmailId

@sherlockvn sherlockvn force-pushed the feature/add-mdn-send-parse branch from 8ab5958 to a8bab3d Compare October 6, 2022 14:14
@dab246 dab246 requested review from ManhNTX and hoangdat October 7, 2022 05:55
@dab246 dab246 changed the title Feature/add mdn send parse Implement MDN/send method/response Oct 7, 2022
@hoangdat hoangdat merged commit f5652f2 into master Oct 10, 2022
@dab246 dab246 deleted the feature/add-mdn-send-parse branch November 1, 2022 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants