Skip to content

CloudNcodeInc/sendgrid-django

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SendGrid-django

<<<<<<< HEAD Simple Django back-end to send email using SendGrid’s Web API.

Warning:

Sendgrid API only handles plain text and HTML type of content. Any e-mail alternative content with an unhanded type of content will be dropped! ======= Simple django backend to send email using SendGrid's Web API. >>>>>>> upstream/master

Installation

Install the backend from PyPI:

pip install sendgrid-django

Add the following to your project's settings.py:

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

Or, SendGrid username and password can be used instead of an API key:

EMAIL_BACKEND = "sgbackend.SendGridBackend"
SENDGRID_USER = "Your SendGrid Username"
SENDGRID_PASSWORD = "Your SendGrid Password"
SENDGRID_RAISE_UNHANDLED = True

Done!

Example

from django.core.mail import send_mail
from django.core.mail import EmailMultiAlternatives

send_mail("Your Subject", "This is a simple text email body.",
  "Yamil Asusta <hello@yamilasusta.com>", ["yamil@sendgrid.com"])

# or
mail = EmailMultiAlternatives(
  subject="Your Subject",
  body="This is a simple text email body.",
  from_email="Yamil Asusta <hello@yamilasusta.com>",
  to=["yamil@sendgrid.com"],
  headers={"Reply-To": "support@sendgrid.com"}
)
mail.attach_alternative("<p>This is a simple HTML email body</p>", "text/html")

mail.send()

MIT

Enjoy :)

About

Simple django backend to send email through SendGrid

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%