Send email two ways via our REST API:
Reminder: You can also send email via SMTP with Mailgun. Please reference the user manual.
Pass the components of the messages such as To, From, Subject, HTML and text parts, attachments, etc. Mailgun will build a MIME representation of the message and send it. Note: In order to send you must provide one of the following parameters: 'text', 'html', 'amp-html' or 'template'
from required | string Email address for |
to required | string Email address of the recipient(s). Example: |
subject required | string Message subject |
html required | string Body of the message (HTML version) |
cc | string Same as |
bcc | string Same as |
text | string Body of the message (text version) |
t:variables | string A valid JSON-encoded dictionary used as the input for template variable expansion. See Templates for more information |
amp-html | string AMP part of the message. Please follow Google guidelines to compose and send AMP emails |
t:version | string Use this parameter to send a message to specific version of a template |
t:text | string Pass |
o:time-zone-localize | string Toggles Timezone Optimization (TZO) on a per message basis. String should be set to preferred delivery time in |
o:tag | string Tag string. See Tagging for more information |
o:dkim | string Enables/disables DKIM signatures on a per-message basis. Pass |
o:deliverytime | string Specifies the scheduled delivery time in RFC-2822 format (https://mailgun-docs.redoc.ly/docs/mailgun/api-reference/intro/#date-format). Depending on your plan, you can schedule messages up to 3 or 7 days in advance. If your domain has a custom message_ttl (time-to-live) setting, this value determines the maximum scheduling duration. |
template | string Name of a template stored via template API. See Templates for more information |
o:deliverytime-optimize-period | string Toggles Send Time Optimization (STO) on a per-message basis. String should be set to the number of hours in |
attachment | string File attachment. You can post multiple |
o:require-tls | string If set to |
o:testmode | string Enables sending in test mode. Pass |
o:tracking | string Toggles tracking on a per-message basis, see Tracking Messages for details. Pass |
o:tracking-clicks | string Toggles clicks tracking on a per-message basis. Has higher priority than domain-level setting. Pass |
o:tracking-opens | string Toggles opens tracking on a per-message basis. Has higher priority than domain-level setting. Pass |
h:X-My-Header | string
|
o:skip-verification | string If set to |
v:my-var | string
|
recipient-variables | string A valid JSON-encoded dictionary, where key is a plain recipient address and value is a dictionary with variables that can be referenced in the message body. See Batch Sending for more information |
inline | string Attachment with |
{- "message": "Queued. Thank you.",
- "id": "message-id"
}
Build a MIME string yourself using a MIME library for your programming language and submit it to Mailgun.
to required | string Email address of the recipient(s). Example: |
message required | string MIME string of the message. Make sure to use |
v:my-var | string
|
o:tag | string Tag string. See Tagging for more information |
o:dkim | string Enables/disables DKIM signatures on a per-message basis. Pass |
o:tracking-clicks | string Toggles clicks tracking on a per-message basis. Has higher priority than domain-level setting. Pass |
o:tracking-opens | string Toggles opens tracking on a per-message basis. Has higher priority than domain-level setting. Pass |
h:X-My-Header | string
|
o:tracking | string Toggles tracking on a per-message basis, see Tracking Messages for details. Pass |
o:deliverytime | string Specifies the scheduled delivery time in RFC-2822 format (https://mailgun-docs.redoc.ly/docs/mailgun/api-reference/intro/#date-format). Depending on your plan, you can schedule messages up to 3 or 7 days in advance. If your domain has a custom message_ttl (time-to-live) setting, this value determines the maximum scheduling duration. |
o:testmode | string Enables sending in test mode. Pass |
{- "message": "Queued. Thank you.",
- "id": "message-id"
}
Event(s) created from sending an email with Mailgun will contain a storage.key
to use to retrieve the email.
A 200 response
A 404 response
{- "content_transfer_encoding": "7bit",
- "recipients": "cool.barr@cool.com, bar.baz@gmail.com",
- "X-Mailgun-Tag": "earth",
- "From": "foo.bar@my-domain.com",
- "Mime-Version": "1.0",
- "Body-Plain": "This is some html",
- "content_type": "text/html; charset=ascii",
- "Subject": "\"Mailgun is awesome\"",
- "sender": "foo.bar@my-domain.com",
- "subject": "\"Mailgun is awesome\"",
- "stripped-html": "<html>This is some html</html>",
- "Message-Id": "<xxxxxxxxxxxxx.111111111111111@my-domain.com>",
- "To": "cool.barr@cool.com, bar.baz@gmail.com",
- "from": "foo.bar@my-domain.com",
- "stripped-text": "This is some html",
- "Body-HTML": "<html>This is some html</html>",
- "Message-Headers": [
- [
- "Mime-Version",
- "1.0"
], - [
- "Subject",
- "\"Mailgun is awesome\""
], - [
- "From",
- "foo.bar@my-domain.com"
], - [
- "To",
- "cool.barr@cool.com, bar.baz@gmail.com"
], - [
- "X-Mailgun-Tag",
- "universe"
], - [
- "Message-Id",
- "<xxxxxxxxxxxxx.111111111111111@my-domain.com>"
], - [
- "Content-Transfer-Encoding",
- "7bit"
], - [
- "Content-Type",
- "text/html; charset=ascii"
]
]
}
Provides default and scheduled message queue information.
A 200 response
required | object |
required | object |
A 401 response
A 404 response
{- "regular": {
- "is_disabled": true,
- "disabled": {
- "until": "Mon, 02 Jan 2006 15:04:05 MST",
- "reason": "You have too many messages in queue"
}
}
}
Deletes all scheduled and undelivered mail from the domain queue. This endpoint must be called on the storage API host and in the domain's region. e.g. https://storage-us-east4.api.mailgun.net/v3/example.com/envelopes
The storage hosts are storage-us-east4.api.mailgun.net
, storage-us-west1.api.mailgun.net
, and storage-europe-west1.api.mailgun.net
.
{- "message": "done"
}