def send(self):
sg = sendgrid.SendGridAPIClient(
apikey=settings.DJANGO_SENDGRID_PARSE_API)
data = {
'personalizations': [
{
'to': [
{
'email': mail
} for mail in self.to
],
'substitutions': self.body,
'subject': self.subject,
}
],
'from': {
'email': self.from_email
},
'template_id': self.template_id,
}
try:
response = sg.client.mail.send.post(request_body=data)
except urllib.HTTPError as e:
print(e.read())
评论列表
文章目录