我是 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
关于python - SMTPAuthenticationError at/password-reset/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55516946/