Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dos's avatar
Level 2

What is a Mailgun Sandbox for if I can't use it on localhost?

Hello,

When I try to use my Mailgun sandbox to send an email I see the following error:

Client error: `POST https://api.mailgun.net/v3/sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org/messages.mime` resulted in a `400 BAD REQUEST` response:
{
"message": "Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authoriz (truncated...)

So I looked into how to add my domain in my Mailgun account. My local Laravel app runs on the local domain myapp.app. Adding that to Mailgun is obviously not going to work as it only exists on my computer, plus even if I did it would ask me to add DNS records which I can't do on my local machine.

Another Laracasts user @Elimentz asks a similar question here:

https://laracasts.com/discuss/channels/laravel/sending-emails-with-mailgun

How are you supposed to send emails in a development setting using Mailgun?

I would very much appreciate some help on this, I know there is a simple answer but I'm just not seeing it!

Thanks everyone. David

0 likes
7 replies
Mikoop's avatar

Any resolution to this one? testing in sandbox mode would only make sense to test via a localhost domain I would of thought. if anyone could shed any light on this one.

thanks,

Michael

neonexxa's avatar

added my recipient, and verified it, still no luck .. same error ..

Nash's avatar

@B-McLeod As long as you are using Mailgun's sandbox domain, you can only send to the addresses you have specified under authorized recipients. Example: if you want to send an email to [email protected], you need to add that address via Mailgun's admin panel first. If you want to send freely to any address, you must first add and verify a real domain with Mailgun.

If you just want to test emails, you could use something like Mailtrap.

training63's avatar

Hi guys any luck on this? I am having the same problem, sandbox account is place and its credentials and everything is correctly placed on .env file also I have added 3 authorized email addresses still no luck. It says;

Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authoriz

Please or to participate in this conversation.