使用sendgrid-python和模板

问题描述

我尝试使用官方回购中的示例:

import os
from sendgrid import SendGridapiclient
from sendgrid.helpers.mail import *

message = Mail(
    from_email=Email('noreply@mail.co'),to_emails=To(email='mail@gmail.com'),subject='Sending with Twilio SendGrid is Fun',html_content=Content(
        "text/plain","and easy to do anywhere,even with Python"
    )
)
message.template_id = '6b02f312-ad80-4d7e-815a-24be029fd05b'
message.dynamic_template_data = {
    '%email%': 'some email','%location_city%': 'dsadsad',}


sg = SendGridapiclient(
    'SG.key')
response = sg.client.mail.send.post(request_body=message.get())

没有模板,一切似乎都很好,我收到了电子邮件。但是随着它们返回python_http_client.exceptions.BadRequestsError

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)