Site icon Mailtrap

Mailgun Sandbox Domain Explained

It’s perfectly natural to send some test emails before reaching out to real users. If you don’t have to send them from your actual domain – that’s even better. That’s precisely what you can do with Mailgun Sandbox.

How does it work? Is it sufficient for email testing purposes? Let’s see.

How does Mailgun Sandbox work?

Each Mailgun account comes with an individual sandbox domain at no additional cost. When testing email sending from Mailgun, you can use this domain instead of your actual business domain. As a result, the reputation of your real domain won’t be affected in any way.

To get started, create a Mailgun account if you don’t have one already and activate it. Then, open your individual dashboard and in the menu to the left pick Sending -> Domains. You’ll see here the list of configured domains + a sandbox domain assigned to your account. In our case, it’s the only one that made it to this list.

Click on the Mailgun Sandbox domain to see its settings. 

With sandbox domains, you can only send emails to up to five authorized recipients. Even if you’re using a test mode (more on this below) and not delivering any emails, you’ll need to get the authorization from each individual recipient.

To do so, type in their email address and they’ll immediately receive a verification email.

Once approved, the status will update on the list. Unverified recipients will remain, well, “unverified”.

Once you have this sorted out, pick the method for sending emails from your sandbox domain – API or SMTP – and follow the integration instructions.

Here’s a sample email you could send to test if everything works as expected:

curl -s --user 'api:YOUR_API_KEY' \
    https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages \
    -F from='Excited User <mailgun@YOUR_DOMAIN_NAME>' \
    -F to=bill@gates.com \
    -F to=warren@buffet.com \
    -F subject='Hello, it’s me' \
    -F text='Got some money to spare? Looking for an investor.'

Of course, insert your API key and your sandbox domain into the respective fields and send the request. If you receive the following response, you’re all good:

{
  "message": "Queued. Thank you.",
  "id": "<20111114174239.25659.5817@samples.mailgun.org>"
}

In case you receive ‘Domain not found’, double-check that you have copied the correct sandbox domain. If the response is ‘Forbidden’, something’s wrong with your API key.

Since the emails should hit your recipients’ inboxes shortly, you’ll also be able to preview how they look. Naturally, you can format them freely with HTML and CSS and can also utilize MIME strings. See various examples in Mailgun Docs.

How else can you test emails in Mailgun?

Mailgun also has a number of other tools and features for email testing.

First of all, there’s a test mode. You activate it by simply adding ‘o:testmode’ as a parameter of your message and setting it to ‘true’. Example:

curl -s --user 'api:YOUR_API_KEY' \
    https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages \
    -F from='Excited User <mailgun@YOUR_DOMAIN_NAME>' \
    -F to=elon@musk.com \
    -F subject='Hello, it's me' \
    -F text='Looking for an investor. Contact me'
    -F o:testmode='true'

Mailgun will accept this message (as long as the domain and API key are configured properly) but it will not send it to Elon. Note that testmode requests still use up your Mailgun credits.

Mailgun also features an email verification API. You can integrate it directly into your webforms and immediately catch typos in email addresses from popular providers, such as Gmail or Yahoo!. This way, you won’t send to mistyped addresses and won’t hurt your reputation this way.

Finally, Mailgun also features built-in tools for previewing emails. You can easily test your sequences and see how they would look on a wide range of devices and screen sizes.

Pros and Cons of Mailgun Sandbox

The sandbox domain clearly has some compelling advantages:

There’s also a number of cons:

What to use if Mailgun Sandbox isn’t enough?

While there is no denying that Mailgun Sandbox comes in very handy for testing a new integration or just trying out Mailgun as an ESP, it’s not the most feature-packed email testing tool out there. 

So, if you’re looking for something with more functionality that can solve a range of email testing challenges, check out solutions like Mailtrap Email Sandbox instead.

Mailtrap Email Sandbox, the email testing side of the Mailtrap Delivery Platform, captures all SMTP traffic from staging and dev environments and provides a range of features for inspecting and debugging emails that make up that traffic. This way, it creates a safe environment for email testing that comes with no risk of spamming real recipients. 

On top of that, there are quite a few features that come with Email Sandbox, such as:

Multiple inboxes for different projects and stages of projects – enables users to quickly find data, switch between tasks, and share testing results with colleagues/clients. 

HTML Check – scans through email HTML code, looking for any problematic elements, and also estimates the support for that code across popular email clients.

Email preview (HTML tab) – shows how an email is rendered by a web browser allowing you to spot any issues with responsiveness, images, links, variables, and content.

Spam Analysis – provides a spam report and a blacklist report, with the former including an overall spam score and the latter information on whether the sender’s IP or domain is listed on any commonly used blacklists. 

Tech Info shows users the original values of email headers as well as SMTP transaction info.

Email forwarding (automatic and manual) enables whitelisted recipients to receive your testing emails, thus facilitating better collaboration with colleagues/clients, previewing emails in different email clients/apps/real inboxes, and using Mailtrap as a proxy between your application and your email client.

To start using Mailtrap Email Sandbox, all you need to do is create a Mailtrap account and complete a straightforward 5-minute setup. After that is done, you can enjoy the above-mentioned features along with benefits such as automation, preservation of domain reputation, and much more. 

Exit mobile version