2

I am currently testing Mailgun. Therefore, I don't want to add any payment information at the moment.

So, I'm working with the sandbox, and a verified address in the authorized recipients attached to the sandbox. So far, following the documentation, this limited setup is supposed to be working for testing purpose.

I use Postman to better identify how to work with the API, excluding any potential issues with coding.

Here is my Hello World config:

POST https://api:____my_API_Key___@api.mailgun.net/v3/sandboxXXXXX.mailgun.org/messages

The dashboard indicates that the sandbox is located in the US, so I don't use the european API.

Body:

  • from: postmaster@sandboxXXX.mailgun.org (also tried the verified email address, and postmaster <postmaster@sandbox...>)
  • to: bob@marley.com (the verified email address)
  • subject: test
  • text: Hello World!

I get a 400 error, Bad Request, and the documentation suggests to look for missing parameters.

The other posts I found so far did not help me to find the error spot either.

Also, Mailgun provides a Postman collection. But it did not help either.

Indeed, I dream of a detailed information of the API requirements, value formating... What are the required parameters if the error means I miss some?

Any idea of what I am missing?

Yako
  • 3,405
  • 9
  • 41
  • 71
  • This detailed description may help you: https://stackoverflow.com/questions/68150905/can-i-send-email-with-mailgun-sandbox-domain-under-my-local-os/68542876#68542876 – FredyWenger Jul 27 '21 at 10:14
  • Thanks. However, a credit card is not available in every situation, especially when testing a product for another party. In these use cases the sandbox is really useful, if it can demonstrate the product abilities. Sadly, MG sandbox is poorly documented, and does not help much for new users onboarding. – Yako Jul 29 '21 at 07:28

1 Answers1

0

Here is the solution.

I had to guess and analyze some examples from the provided Postman Collection to find out what the documentation is supposed to explain in the first place:

4 Required headers:

Authorization

Value : Basic XXXXX, where XXXXX is the Base 64 encoded version of api:___your_API_key___.

Content-Type

Value : multipart/form-data; boundary=XXX, where XXX is any short single string that will be used to identify a boundary within the sent content.

Content-Length

Value : XXX, where XXX is the size of the body request.

Host

Value : mydomain.com, your IP if sending from Postman...

Yako
  • 3,405
  • 9
  • 41
  • 71