【问题标题】:SMTPAuthenticationError at /password-reset//password-reset/ 处的 SMTPAuthenticationError
【发布时间】:2019-08-26 06:27:12
【问题描述】:

我是 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。 你能帮我在这里做错什么吗! 如果你想看到完整的错误。

/password-reset/ 处的 SMTPAuthenticationError (535, b'5.7.8 用户名和 密码不被接受。

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

网址:http://localhost:8000/password-reset/ 异常类型:SMTPAuthenticationError b'5.7.8 用户名和密码不被接受。在\n5.7.8 了解更多信息 https://support.google.com/mail/?p=BadCredentialsa24sm3958276ljd.32 - gsmtp') 异常 位置:C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\smtplib.py 在 auth 中,第 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在\n5.7.8了解更多信息请求方法:POST 请求Django 版本:2.1.7异常值:(535,

【问题讨论】:

    标签: python django django-settings change-password smtp-auth


    【解决方案1】:

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

    看看这个答案,它也可能对你有所帮助:SMTPAuthenticationError when sending mail using gmail and python

    【讨论】:

    • 是的,谢谢你。上面提供的第一个链接是这个烂摊子的解决方案。我的环境变量设置得很好。
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      2022 年 2 月更新:

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

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

        https://myaccount.google.com/lesssecureapps

      2. 允许访问您的 Google 帐户:开启(点按“继续”)↓↓↓

        https://accounts.google.com/DisplayUnlockCaptcha

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-04-09
        • 1970-01-01
        • 2019-06-26
        • 2018-07-18
        • 2014-02-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多