如何使用C / C ++使用Mailgun发送电子邮件?

问题描述 投票:-1回答:1

我正在使用此simple ArduinoHttpClient example code将示例POST请求从我的Arduino Uno Wifi Rev 2发送到可公开访问的URL。有用。我得到合法答复。

但是现在,我想从我的Arduino代码发送一个HTTP请求,该请求模仿此curl调用以发送电子邮件via MailGun

curl \
--request POST \
--header 'Content-Type: application/x-www-form-urlencoded' \
--user 'api:XXX-my-API-key-obtained-from-mailgun-website-XXX' \
--data-urlencode from='Mailgun Sandbox <[email protected]>' \
--data-urlencode to='Me <[email protected]>' \
--data-urlencode subject='Hello World1' \
--data-urlencode text='Hello World2' \
"https://api.mailgun.net/v3/sandbox7d1aaf2f157f42d8844b1ac4c38a0ef7.mailgun.org/messages"

我该怎么办?当我用代理拦截了curl调用时,我看到它正在发送以下字节:

POST https://api.mailgun.net/v3/sandbox7d1aaf2f157f42d8844b1ac4c38a0ef7.mailgun.org/messages HTTP/1.1
Host: api.mailgun.net
Authorization: Basic YYY-basic-auth-token-YYY
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

很难用C ++重新创建它。如何确定Authorization令牌?必须有一种惯用的/众所周知的方法。

Mailgun网站列出了几种语言的示例片段,但not C/C++

enter image description here

c++ c mailgun
1个回答
0
投票

请仔细阅读本文档documentation on how to send mail using mailgun,查看是否有帮助

© www.soinside.com 2019 - 2024. All rights reserved.