I'm using this simple ArduinoHttpClient example code to send a sample POST request from my Arduino to a publicly accessible URL. It works. I get a legit response.
But now, I want to send a HTTP request from my Arduino code that mimics this curl call to send an email via MailGun:
curl \
--request POST \
--header 'Content-Type: application/x-www-form-urlencoded' \
--user 'api:my-api-key-obtained-from-mailgun-website' \
--data-urlencode from='Mailgun Sandbox <postmaster@sandbox7d1aaf2f157f42d8844b1ac4c38a0ef7.mailgun.org>' \
--data-urlencode to='Me <myemail@gmail.com>' \
--data-urlencode subject='Hello World1' \
--data-urlencode text='Hello World2' \
"https://api.mailgun.net/v3/sandbox7d1aaf2f157f42d8844b1ac4c38a0ef7.mailgun.org/messages"
How can I do it? When I intercepted this curl call with a proxy, I see that it is sending these bytes:
POST https://api.mailgun.net/v3/sandbox7d1aaf2f157f42d8844b1ac4c38a0ef7.mailgun.org/messages HTTP/1.1
Host: api.mailgun.net
Authorization: Basic XXXXXX-How-Was-This-Token-Acquired??-XXXXXXXXXXX
User-Agent: curl/7.54.0
Accept: */*
Content-Type: application/x-www-form-urlencoded
Content-Length: 183
from=Mailgun%20Sandbox%20%3Cpostmaster%40sandbox7d1aaf2f157f42d8844b1ac4c38a0ef7.mailgun.org%3E&to=Me%20%3Cmyemail%40gmail.com%3E&subject=Hello%20World1&text=Hello%20World2
It's difficult to recreate that in C++. How is that Authorization token acquired? There must be an idiomatic/well-known way to do this.
The MailGun website lists examples snippets from several languages, but not C/C++.
