SMTPAuthentication错误在 /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。 你能帮我什么我在这里做错了什么吗! 如果您想查看完整错误。

SMTPAuthentication错误在/password-reset/(535, b'5.7.8 用户名和 不接受密码。

https://support.google.com/mail/?p=BadCredentials a24sm3958276ljd.32 - gsmtp')

网址: http://localhost:8000/password-reset/异常类型:SMTP 身份验证错误 b'5.7.8 不接受用户名和密码。有关详细信息,请访问5.7.8 https://support.google.com/mail/?p=BadCredentials a24sm3958276ljd.32 - gsmtp') 例外 位置: C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\smtplib.py 在身份验证中,第 642 行 Python 可执行文件:C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe Python 版本: 3.7.2 Python 路径:
['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'] 服务器时间:2019 年 4 月 4 日星期四 12:24:22 +0000 了解更多信息5.7.8请求方法:POST 请求 请求姜戈版本:2.1.7异常值:(535,

您介意仔细检查您的环境变量是否设置正确吗?另外,您是否在Google帐户上启用了此功能:https://www.google.com/settings/security/lesssecureapps?

看看这个答案,因为它也可能对你有所帮助: SMTPAuthentication使用gmail和python发送邮件时出错

就我而言,它在我的本地机器上工作,但不在 heroku 服务器上工作。我继续这个链接 https://accounts.google.com/DisplayUnlockCaptcha ,然后单击继续。之后,我不得不重新登录我的gmail帐户。它开始工作了。希望它可以帮助某人!

> 2022 年 2 月更新:

你需要做两件事来克服谷歌非常强大的安全性

  1. 允许安全性较低的应用:

    ↓↓↓https://myaccount.google.com/lesssecureapps

  2. 允许访问您的谷歌帐户:开启(点击"继续")↓↓↓

    https://accounts.google.com/DisplayUnlockCaptcha

最新更新