Error when submitting variables through Mailgun with Python

偶尔善良 提交于 2020-08-09 12:04:43

问题


I'm trying to send mail through Mailgun with Python, in that instance I'm trying to push a variable alongside.

My code is the following:

requests.post("MailGun URL",
              auth=("api", "api-key"),
              data={
                  "from":"From_Mail",
                  "to":["To_Mail"],
                  "template":"template_name",
                  "subject":"Testing some things",
                  "h:X-Mailgun-Variables": {"firstname": "John"}
              })

If I use the above without "X-Mailgun-Variables" I'm not experiencing any problems, but with the above I get the following error message:

"delivery-status": {
        "code": 621,
        "message": "",
        "attempt-no": 1,
        "description": "Failed to decode variables",
        "session-seconds": 0
    }

What am I doing wrong?

Thanks in advance,


回答1:


I found the solution myself - for future reference:

"h:X-Mailgun-Variables": {"firstname": "John"}

The above ss only for SMTP use.

For API use:

"v:firstname":"John"


来源:https://stackoverflow.com/questions/59493081/error-when-submitting-variables-through-mailgun-with-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!