使用Python通过Mailgun提交变量时出错

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

我正在尝试使用Python通过Mailgun发送邮件,在这种情况下,我试图将变量推入其中。

我的代码如下:

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"}
              })

如果我在不使用“ X-Mailgun-Variables”的情况下使用上面的命令,我没有遇到任何问题,但是使用上面的命令,我收到以下错误消息:

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

我在做什么错?

谢谢,

python mailgun
1个回答
0
投票

我自己找到了解决方案-供以后参考:

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

以上仅用于SMTP的SS。

供API使用:

"v:firstname":"John"
© www.soinside.com 2019 - 2024. All rights reserved.