No module named 'sendgrid_backend' in django

会有一股神秘感。 提交于 2020-07-21 11:28:09

问题


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


回答1:


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
# https://github.com/sklarsa/django-sendgrid-v5
EMAIL_BACKEND = 'sendgrid_backend.SendgridBackend'
SENDGRID_API_KEY = '<SENDGRID_API_KEY>'

I think you should follow this




回答2:


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'


来源:https://stackoverflow.com/questions/60014049/no-module-named-sendgrid-backend-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!