No Module Named 'Sendgrid_Backend' in Django

When sending an email on heroku I get this error:

No module named 'sendgrid_backend'

I have this set up in settings.py:

EMAIL_BACKEND = "sendgrid_backend.SendgridBackend"
SENDGRID_API_KEY = os.environ.get("SENDGRID_API_KEY")
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'apikey'
EMAIL_HOST_PASSWORD = os.environ.get('SENDGRID_API_KEY')

I also did install of sendgrid using pip and included it in the requirements.txt

4

5 Answers

I think this will help you First, install the package

pip install sendgrid-django

and then create requirements.txt, email backend should be like this

EMAIL_BACKEND = "sgbackend.SendGridBackend"

or you can also do this

pip install django-sendgrid-v5
# 
EMAIL_BACKEND = 'sendgrid_backend.SendgridBackend'
SENDGRID_API_KEY = '<SENDGRID_API_KEY>'

I think you should follow this

4

After some tinkering around, this worked for me:

SENDGRID_API_KEY = os.environ.get("SENDGRID_API_KEY")
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'your sendgrid user name'
EMAIL_HOST_PASSWORD = 'your sendgrid password'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'your sendgrid email'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
1

For my case, I just needed to switch to this:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

The sendgrid dependency is fine, just needed a different email backend setting.

what you simply need to do is this:

EMAIL_BACKEND = "sgbackend.SendGridBackend"

and make sure you have installed sendgrid-django using:

pip install sendgrid-django

this just worked for me

You need to add

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

But also if you get an SMTPSenderRefused with 550, b'Unauthenticated senders not allowed' error you have to go to the SendGrid website and authenticate your sender email, aka the email from which you want to send something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest