GET /domains/{mydomain}/messages/{messagekey}
To retrieve an inbound message that has been stored via the store() action, use the URL found in the stored event (which you can find through the Events API, or in the notify webhook set when creating the store action (store(notify="http://mydomain.com/callback")).
- By default the message will be returned in JSON form with parsed parts. Links to the attachments will be included.
- You can also retrieve the full raw mime message (attachments and all) if you make the request to the URL with the
Acceptheader set tomessage/rfc2822. - Stored messages are encoded with Quoted-printable encoding. Decoding samples are available in the examples section below.
These are the parameters of the JSON returned from a GET request to a stored message url.
| Parameter | Type | Description |
|---|---|---|
| recipients | string | recipient of the message as reported by MAIL TO during SMTP chat. |
| sender | string | sender of the message as reported by MAIL FROM during SMTP chat. Note: this value may differ from From MIME header. |
| from | string | sender of the message as reported by From message header, for example “Bob Lee blee@mailgun.net”. |
| subject | string | subject string. |
| body-plain | string | text version of the email. This field is always present. If the incoming message only has HTML body, Mailgun will create a text representation for you. |
| stripped-text | string | text version of the message without quoted parts and signature block (if found). |
| stripped-signature | string | the signature block stripped from the plain text message (if found). |
| body-html | string | HTML version of the message, if message was multipart. Note that all parts of the message will be posted, not just text/html. For instance if a message arrives with “foo” part it will be posted as “body-foo”. |
| stripped-html | string | HTML version of the message, without quoted parts. |
| attachments | string | contains a json list of metadata objects, one for each attachment, see below. |
| message-headers | string | list of all MIME headers dumped to a json string (order of headers preserved). |
| content-id-map | string | JSON-encoded dictionary which maps Content-ID (CID) of each attachment to the corresponding attachment-x parameter. This allows you to map posted attachments to tags like <img src='cid'> in the message body. |
Note Do not rely on the
body-plain,stripped-text, andstripped-signaturefields for HTML sanitization. These fields merely provide content from the text/plain portion of an incoming message. This content may contain unescaped HTML.
The attachments JSON contains the following items.
| Parameter | Type | Description |
|---|---|---|
| size | integer | indicates the size of the attachment in bytes. |
| url | string | contains the url where the attachment can be found. This does not support DELETE. |
| name | string | the name of the attachment |
| content-type | string | the content type of the attachment |
These are the parameters when the Accept header is set to message/rfc2822
| Parameter | Type | Description |
|---|---|---|
| recipient | string | recipient of the message. |
| sender | string | sender of the message as reported by SMTP MAIL FROM. |
| from | string | sender of the message as reported by From message header, for example “Bob bob@example.com”. |
| subject | string | subject string. |
| body-mime | string | full MIME envelope. You will need a MIME parsing library to process this data. |
Servers
- https://api.mailgun.net
- https://api.eu.mailgun.net
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
mydomain |
String | Yes | |
messagekey |
String | Yes |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.