[Django]-Setting up email with Sendgrid in Heroku for a Django App

39👍

Within your settings.py include:

import os
EMAIL_HOST_USER = os.environ['SENDGRID_USERNAME']
EMAIL_HOST= 'smtp.sendgrid.net'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_PASSWORD = os.environ['SENDGRID_PASSWORD']

Edit: changed EMAIL_PASSWORD to EMAIL_HOST_PASSWORD as that’s the correct spelling.

0👍

In the intervening 10 years, the above answer has become obsolete. Sendgrid now uses an API key.

https://docs.sendgrid.com/for-developers/sending-email/django

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

Leave a comment