sendgrid api的django电子邮件后端

django-sgapi的Python项目详细描述


SendGrid API的Django电子邮件后端

https://travis-ci.org/jtstio/django-sgapi.svg?branch=masterhttps://codecov.io/gh/jtstio/django-sgapi/branch/master/graph/badge.svghttps://badge.fury.io/py/django-sgapi.svg

安装

从pypi安装后端:

pip install django-sgapi

在项目的settings.py中添加以下内容:

EMAIL_BACKEND="sgbackend.SendGridBackend"SENDGRID_API_KEY="Your SendGrid API Key"

完成!

示例

fromdjango.core.mailimportsend_mailfromdjango.core.mailimportEmailMultiAlternatives# Send a simple messagesend_mail('Hello there!','Emails are the future!','Jay Hale <jay@jtst.io>',['hello@sink.sendgrid.net'])# Send a more complex messagemail=EmailMultiAlternatives(subject='Hello there again!',body='Who knew you could do so many things with email?!?',from_email='Jay Hale <jay@jtst.io>',to=['hello@sink.sendgrid.net'],)mail.reply_to='No Reply <no-reply@sink.sendgrid.net>'mail.template_id='marketing_template_5'mail.substitutions={'%organization%':'jtstio'}withopen('flyer.pdf','rb')asfile:mail.attachments=[('flyer.pdf',file.read(),'application/pdf')]mail.attach_alternative("<p>Who knew you could do <strong>so many things</strong> with email?!?</p>","text/html")mail.send()

归因

sendgrid-django-v5:一个 您应该查看替代实现

sendgrid-django:这个的基础 实施

sendgrid-python:Python SendGrid连接器

许可证

麻省理工学院

享受:)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用Spring和JSF向客户端授予临时权限   java除了Array/ArrayList之外,还有其他保存矩阵元素的方法吗   java BeanValidation不适用于单选按钮   通过java程序连接到配置单元数据库时出错   java如何使用maven解决二级依赖关系   JfreeChart/Java中带有图例的数据表   合并数组时发生java运行时错误   安全性如何在JavaEE中保护WebSocket端点?   java有没有一种方法可以使用insert方法为树插入值   java编程“静态”的另一种方式:代码可以吗?   java阅读文本文件时如何跳过3行   %04X在C中的含义以及如何在java中编写   java我如何验证一个方法不是仅在一个测试范围内对模拟调用的?   java如何在mac中使用启动appium desktop 1.6.1。球棒   仅匹配最多10位小数的java正则表达式