如何解决使用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 举报,一经查实,本站将立刻删除。