Skip to content
Last updated

Storing and Retrieving Messages

When storing an email through a store() action in a Route, you can choose to be notified when the message is stored by including a URL with the notify parameter when setting up the store action or you can retrieve the message later by searching for the message through the Logs API and retrieving it through the Messages API.

When you set a URL to be posted when the message is received:

(store(notify="http://mydomain.com/callback") or retrieve the message later through a GET request to the Messages API, the following parameters are posted/returned in JSON.

If at least one attachment is written, then the resulting body will have a multipart/form-data content type, otherwise it will have an application/x-www-form-urlencoded content type.

ParameterTypeDescription
domainStringThe domain name this message was received from.
recipientstringThe recipient of the message as reported by MAIL TO during SMTP chat
senderstringThe sender of the message as reported by MAIL FROM during SMTP chat. (This value may differ from the MIME header)
fromstringThe sender of the message as reported by from message header, for example "Bob Lee <blee@mailgun.net>".
subjectstringThe subject string
body-plainstringThe 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-textstringThe text version of the message without the quoted parts and signature block (if found)
stripped-signaturestringThe signature block stripped from the plain text message (if found)
body-htmlstringThe 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-htmlstringThe HTML version of the message, without the quoted parts
attachmentsstringThe string that contains a JSON list of metadata objects, one for each attachment.
message-urlstringA URL that you can use to get and/or delete the message. Only present in the payload posted to the notification URL
timestampintThe number of seconds passed since January 1, 1970 (See Securing Webhooks)
tokenstringA randomly generated string with a length of 50 (See Securing Webhooks)
signaturestringA string with hexadecimal digits generated by HMAC algorithm (See securing webhooks).
message-headersstringA list of MIME headers dumped to a JSON string (The o_rder of headers is preserved)_
Content-id-mapstring

Alternatively, you can choose the following parameters when the Accept header is set to message/rfc2822

ParametertypeDescription
recipientstringThe recipient of the message
senderstringThe sender of the message
fromstringThe sender of the message as reported by the from message header. Example: <bob@example.com>"
subjectstringThe subject string
`Body-mimestringThe Full MIME envelope. You will need a MIME parsing library to process this data