---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/sendgrid/for-developers/sending-email/django#article
headline: Django
description: View instructions on how to send email with Django using SendGrid, by setting up setting up Django's built in mail library.
url: https://www.twilio.com/docs/sendgrid/for-developers/sending-email/django
inLanguage: en
dateModified: 2026-07-17T03:36:59.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# Django

To send email from a Django application with SendGrid, configure Django's built-in email settings to use SendGrid's SMTP relay. Django, a Python web framework, provides a built-in way to send email that works with SendGrid as the delivery service.

For more detail about sending email over SMTP with Django, see the [Django email documentation](https://docs.djangoproject.com/en/dev/topics/email/).

First start by adding the following to **settings.py:**

```python
SENDGRID_API_KEY = os.getenv('SENDGRID_API_KEY')

EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'apikey' # this is exactly the value 'apikey'
EMAIL_HOST_PASSWORD = SENDGRID_API_KEY
EMAIL_PORT = 587
EMAIL_USE_TLS = True
```

Then to send email you can do the following:
Inside yourapp.views.py

```python
from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', 'from@example.com', ['to@example.com'], fail_silently=False)
```

Customize the subject, message, sender email address, and recipients as needed for your use case.

> \[!NOTE]
>
> You may also send emails with Django by using the [django-sendgrid-v5](https://github.com/sklarsa/django-sendgrid-v5) library, which utilizes the [Web API](/docs/sendgrid/api-reference/mail-send/mail-send) instead of SMTP as the transport mechanism.
