/password-reset/ 处的 SMTPAuthenticationError
SMTPAuthenticationError at /password-reset/
我是 Django 的新手。我正在尝试在我的项目中添加一项功能,使用户能够通过给定的电子邮件重置密码。这些配置处于开发阶段而非生产阶段。这是我在settings.py
中的配置
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('EMAIL_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS')
我尝试了这些,但似乎没有任何效果。我也从 gmail 设置中启用了 IMAP。
你能帮我看看我在这里做错了什么吗!
如果你想看到完整的错误。
SMTPAuthenticationError at /password-reset/ (535, b'5.7.8 Username and
Password not accepted.
https://support.google.com/mail/?p=BadCredentials a24sm3958276ljd.32 -
gsmtp')
URL: http://localhost:8000/password-reset/
Exception Type: SMTPAuthenticationError
b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8
https://support.google.com/mail/?p=BadCredentials a24sm3958276ljd.32 -
gsmtp') Exception
Location: C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\smtplib.py
in auth, line 642 Python
Executable: C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe
Python Version: 3.7.2 Python Path:
['C:\Users\Administrator\Desktop\django_project',
'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python37.zip',
'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\DLLs',
'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib',
'C:\Users\Administrator\AppData\Local\Programs\Python\Python37',
'C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages',
'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages']
Server time: Thu, 4 Apr 2019 12:24:22 +0000Learn more at\n5.7.8Request Method: POST RequestDjango Version: 2.1.7Exception Value: (535,
您介意再检查一下您的环境变量是否设置正确吗?此外,您是否在 Google 帐户上启用了此功能:https://www.google.com/settings/security/lesssecureapps?
看看这个答案,它也可能对您有所帮助:SMTPAuthenticationError when sending mail using gmail and python
在我的例子中,它在我的本地机器上工作,但在 heroku 服务器上不工作。我继续这个 link https://accounts.google.com/DisplayUnlockCaptcha
并点击继续。之后我不得不重新登录我的 gmail 帐户。它开始工作了。希望它能对某人有所帮助!
2022 年 2 月更新:
您需要做 2 件事 才能克服 非常强大的 google 安全性。
允许安全性较低的应用程序:开启↓↓↓
允许访问您的 Google 帐户:开启(点击“继续”)↓↓↓
我是 Django 的新手。我正在尝试在我的项目中添加一项功能,使用户能够通过给定的电子邮件重置密码。这些配置处于开发阶段而非生产阶段。这是我在settings.py
中的配置EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('EMAIL_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS')
我尝试了这些,但似乎没有任何效果。我也从 gmail 设置中启用了 IMAP。 你能帮我看看我在这里做错了什么吗! 如果你想看到完整的错误。
SMTPAuthenticationError at /password-reset/ (535, b'5.7.8 Username and Password not accepted.
https://support.google.com/mail/?p=BadCredentials a24sm3958276ljd.32 - gsmtp')
URL: http://localhost:8000/password-reset/ Exception Type: SMTPAuthenticationError b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials a24sm3958276ljd.32 - gsmtp') Exception Location: C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\smtplib.py in auth, line 642 Python Executable: C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe Python Version: 3.7.2 Python Path:
['C:\Users\Administrator\Desktop\django_project', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python37.zip', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\DLLs', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37', 'C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages', 'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages'] Server time: Thu, 4 Apr 2019 12:24:22 +0000Learn more at\n5.7.8Request Method: POST RequestDjango Version: 2.1.7Exception Value: (535,
您介意再检查一下您的环境变量是否设置正确吗?此外,您是否在 Google 帐户上启用了此功能:https://www.google.com/settings/security/lesssecureapps?
看看这个答案,它也可能对您有所帮助:SMTPAuthenticationError when sending mail using gmail and python
在我的例子中,它在我的本地机器上工作,但在 heroku 服务器上不工作。我继续这个 link https://accounts.google.com/DisplayUnlockCaptcha 并点击继续。之后我不得不重新登录我的 gmail 帐户。它开始工作了。希望它能对某人有所帮助!
2022 年 2 月更新:
您需要做 2 件事 才能克服 非常强大的 google 安全性。
允许安全性较低的应用程序:开启↓↓↓
允许访问您的 Google 帐户:开启(点击“继续”)↓↓↓