Email Preview API (1.0.0)
Mailgun Email Preview service with RESTful JSON HTTP API for providing email previews.
https://api.mailgun.net/
https://api.eu.mailgun.net/
- US Mailgun
https://api.mailgun.net/v1/preview/address
- EU Mailgun
https://api.eu.mailgun.net/v1/preview/address
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
-u <username>:<password> \
https://api.mailgun.net/v1/preview/address
{ "preview_address": "string" }
Request
This call returns a list of Email Tests along with metadata about each test. Email Tests are stored for 90 days. When query parameters are provided, only the tests matching the specified criteria will be returned; otherwise, all available tests are returned. The response structure remains identical in both cases.
The starting point of your test date range. Accepts formats like '2025-03-10 17:52:07', Unix timestamp, or 'yesterday'.
The ending point of your test date range. Accepts formats like '2025-03-10 17:52:07', Unix timestamp, or 'yesterday'.
The "subject" field of returned tests must contain the exact string. This search is case-insensitive.
Enterprise users can use this field in a KV array of x-headers submitted with the test. This is an AND match, meaning all headers must be present to return.
- US Mailgun
https://api.mailgun.net/v2/preview/tests
- EU Mailgun
https://api.eu.mailgun.net/v2/preview/tests
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://api.mailgun.net/v2/preview/tests?customer_id=string&from=string&to=string&subject=string&headers=string&results=0&page=0'
[ { "id": "DdbNga1MdL3N7sO19v5MAmpOKIqFrLg9cgpCIgS4othXJ", "date": 1739876826, "type": "email-test", "subject": "subject", "headers": {} }, { "id": "pDdLWjbj3ZbAnHkTbg3QG27mFyoc62OAH1WJXgmb0uNT4", "date": 1739874606, "type": "email-test", "subject": "", "headers": {} } ]
Request
This call creates a new email test and submits it to our system for processing.
All requests must contain a subject property and one source property (either html or url). All other properties are optional. In the following table, each property and its default value is shown.
If content-checking variables (such as those for link validation, image validation, or accessibility) are set in the body of the request, the endpoint will run content-checking on the email content.
The response will include an id property that should be used to request the results or trigger further processes on the email content.
For enterprise customers, the response will also include the customer_id and reference_id that were submitted with the test.
- US Mailgun
https://api.mailgun.net/v2/preview/tests
- EU Mailgun
https://api.eu.mailgun.net/v2/preview/tests
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
-u <username>:<password> \
https://api.mailgun.net/v2/preview/tests \
-H 'Content-Type: application/json' \
-d '{
"subject": "Example subject",
"html": "<html>...</html>",
"transfer_encoding": "base64",
"charset": "utf-8",
"customer_id": "1",
"clients": [
"client1",
"client2"
],
"content_checking": {
"link_validation": true,
"image_validation": true,
"accessibility": true
}
}'
{ "id": "exampleTestID", "customer_id": "1", "warnings": [ { … } ], "content_checking": { "link_validation": { … }, "image_validation": { … }, "accessibility": { … } } }