[英]Authentication Error when trying to reset password - django
I try to reset password with gmail.com.我尝试使用 gmail.com 重置密码。 I think I set everything correct, but it's still doesn't work and raise error like so:
我想我把一切都设置正确了,但它仍然不起作用并引发如下错误:
settings.py设置.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')
I set my enviroment variables EMAIL_USER
(login to my gmail account) and EMAIL_PASS
(16-sign password provided by Google when you use 2-step authentication - Google App Password).我设置了环境变量
EMAIL_USER
(登录到我的 gmail 帐户)和EMAIL_PASS
(当您使用两步身份验证时由 Google 提供的 16 签名密码 - Google App 密码)。 I tried also use password to my gmail account but this also not work.我也尝试将密码用于我的 gmail 帐户,但这也不起作用。 Someone know what I do wrong ?
有人知道我做错了什么吗? Thanks for any help.
谢谢你的帮助。
Change the EMAIL_PORT to be 465将 EMAIL_PORT 更改为 465
EMAIL_PORT = 465
Using smtplib to connect directly to the gmail stmp server it fails with port 587 but works with 465:使用 smtplib 直接连接到 gmail stmp 服务器,它在端口 587 上失败,但在 465 上工作:
server=smtplib.SMTP_SSL('smtp.gmail.com', 465)
account="MY ACCOUNT LOG IN"
password="MY APP PASSWORD"
server.login(account, password)
returns:返回:
(235, b'2.7.0 Accepted')
However然而
server=smtplib.SMTP_SSL('smtp.gmail.com', 587)
account="MY ACCOUNT LOG IN"
password="MY APP PASSWORD"
server.login(account, password)
Gives a time out error.给出超时错误。 And connecting without SSL isn't supported for gmail:
gmail 不支持不使用 SSL 进行连接:
server=smtplib.SMTP('smtp.gmail.com', 587)
account="MY ACCOUNT LOG IN"
password="MY APP PASSWORD"
server.login(account, password)
Returns退货
smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.