SMTP Authentication Error with Django on Heroku

不问归期 提交于 2021-02-08 02:00:09

问题


I am trying to send emails from my django app using the the gmail smtp servers. The emails are being sent when I run the application on my local server. But I'm getting an SMTP Authentication Error while using it on heroku.

Traceback - link

settings.py -

# Email configuration.

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '***************@gmail.com'
EMAIL_HOST_PASSWORD = '************'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = '******************@gmail.com'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

And I have rechecked the account password, also I have enabled the access of less secure apps from my google account. But still I am getting this error.


回答1:


Try using sendgrid, because gmail smtp has some problem. I too was unable to do using gmail smtp. But it worked perfectly using sendgrid. And this is also free for basic use.

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'username'
EMAIL_HOST_PASSWORD = 'userpassword'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'asdf@example.com'



回答2:


Disabling CAPTCHA for clients
If you are not using 2-factor authentication and you have verified the credentials in your Python source are correct, follow these steps:

  1. Login to gmail in your browser
  2. Navigate to the DisplayUnclockCaptcha page.
  3. Click the continue button, and you will see the message
    Account access enabled Please try signing in to your Google account again from your new device or application.

  4. Run your Python script - your login attempt should be successful.




回答3:


Change from mail(@gmail.com) domain to your company domain .then it will work. we can't use from mail domain @gmail.com, DEFAULT_FROM_EMAIL = '******************@yourcompanydomain.com'



来源:https://stackoverflow.com/questions/46020703/smtp-authentication-error-with-django-on-heroku

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