Skip to main content

A Django email backend for the SendGrid API

Project description

A Django email backend for the SendGrid API


Install the backend from PyPI:

pip install django-sgapi

Add the following to your project’s

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



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

# Send a simple message
send_mail('Hello there!', 'Emails are the future!',
  'Jay Hale <>', [''])

# Send a more complex message
mail = EmailMultiAlternatives(
  subject='Hello there again!',
  body='Who knew you could do so many things with email?!?',
  from_email='Jay Hale <>',
mail.reply_to = 'No Reply <>'
mail.template_id = 'marketing_template_5'
mail.substitutions = {'%organization%': 'jtstio'}
with open('flyer.pdf', 'rb') as file:
    mail.attachments = [
        ('flyer.pdf',, 'application/pdf')
    "<p>Who knew you could do <strong>so many things</strong> with email?!?</p>",


sendgrid-django-v5: An alternative implementation you should check out

sendgrid-django: Basis for this implementation

sendgrid-python: Python SendGrid connector



Enjoy :)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sgapi-2.0.0.tar.gz (4.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page