I’m having trouble with my Laravel application when trying to send emails through Mailgun. Every time I attempt to send a message, I get this error:
HTTP 400 Bad Request error from https://api.mailgun.net/v3/sandbox[my-domain].mailgun.org/messages.mime
I’ve been working on this for hours and can’t figure out what’s causing the bad request. My configuration seems correct and I’ve double-checked my API keys. Has anyone encountered this issue before? I’m using the standard Mailgun configuration in my Laravel mail settings but something is clearly wrong with my request format or parameters. Any suggestions on how to debug this would be really helpful.
check your mailgun logs first - they show the actual error details that laravel doesn’t expose. logged into mailgun dashboard and found my issue was invalid from header format. also make sure you’re not mixing up domain vs subdomain in config, that got me once too
Had this exact problem a few months ago - super frustrating! It’s usually the sandbox domain config. Sandbox domains have restrictions that aren’t clear in the docs. Check if you’ve added your recipient email to the authorized recipients list in your Mailgun dashboard first - sandbox can only send to pre-authorized addresses. Make sure your domain string matches exactly what’s in your Mailgun control panel (hyphens, numbers, everything). Also common issue: extra whitespace or hidden characters in your API key or domain name when you copy from the dashboard. Try making a simple test route that dumps your mail config to verify everything’s reading correctly from your env file.
This usually means your domain config doesn’t match what Mailgun wants. I hit the same thing when I first set it up. That 400 error? Your request is probably malformed or missing required fields. Double-check your .env file - make sure MAIL_FROM_ADDRESS matches a verified sender in Mailgun. Also caught me: wrong endpoint. If you’re in EU, use api.eu.mailgun.net, not the default US one. Turn on debug mode and log what’s actually getting sent to Mailgun - you’ll see what’s broken. And check your DNS records in the Mailgun dashboard. Incomplete verification causes weird errors like this.
This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.