emails.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:django-sendgrid-parse 作者: grvty-labs 项目源码 文件源码
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())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号