【发布时间】:2018-07-05 14:45:09
【问题描述】:
我正在尝试使用 python django 使用 sendgrid 发送电子邮件。出于某种原因,正在发送电子邮件,但其中没有 html 内容。我可能做错了什么?
def sendemail(sender,recipient,subject,content,url):
sg = sendgrid.SendGridAPIClient(apikey="")
from_email = Email(sender)
to_email = Email(recipient)
subject = subject
objects = {
"message":content,
"domain":url
}
html_content = get_template('sendemail.html').render(objects)
print ('htmlcontent',html_content)
content = Content("text/html",html_content)
mail = Mail(from_email, subject, to_email, content)
response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.body)
print(response.headers)
【问题讨论】: