When you attempt to send an email through Mailgun and receive the following error response, it indicates a restriction related to sandbox domains:
Status: 400
Response Body:{"message": "Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings."}
Explanation
The error message indicates that you are trying to send an email using a sandbox subdomain. Sandbox domains in Mailgun are intended solely for testing purposes. To resolve this issue, you have two options:
Add Your Own Domain:
- Register a custom domain and verify it with Mailgun. This allows you to send emails from your own domain.
Authorize Recipients:
- If you want to continue using the sandbox domain, you must add the recipient's email address to the list of authorized recipients in your Mailgun account settings. This will permit emails to be sent to those specific addresses.
By following these steps, you can successfully send emails without encountering this error.