python - 在 Django 中使用 Zoho smtp 的身份验证失败

标签 python django authentication smtp smtplib

我正在尝试使用我的 Django 应用程序发送电子邮件。但是在设置 Zoho 帐户并在 settings.py 中添加必要的行后,我仍然无法发送电子邮件,并且它一直显示 SMTPAuthenticationError (535, b'Authentication Failed')

#settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.zoho.com'
EMAIL_HOST_USER = 'administrator@technovate-iiitnr.org'
EMAIL_HOST_PASSWORD = 'mypass'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

#views.py
html =  render_to_string('email/code_email.html',{'code':code})
send_mail('Your Code',
'Hello',
'administrator@technovate-iiitnr.org',
['example@gmail.com'],
html_message=html
)
return render(request,'index.html')

enter image description here

最佳答案

其中一个原因可能是在 zoho 帐户中使用了双因素身份验证。 这可以防止您使用帐户密码,而您需要生成应用程序特定密码并使用相同的密码。 阅读更多 here

关于python - 在 Django 中使用 Zoho smtp 的身份验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41211611/

相关文章:

python - 在子进程之前写出

python - Django - 运行所有测试时仅打印错误

Django 查询返回非 unicode 字符串?

python - Django 1.11 - 项目目录中的模板文件夹

python - 分发 Ruby/Python 桌面应用程序

python - TopLevelLookupException : Can not locate template for uri

javascript - 身份验证后无法访问需要身份验证事件的端点

authentication - 如何在Grails/Spring Security插件中强制未经身份验证的用户进入登录页面

java - 如何使用 xml 配置文件、JAVA、Spring security 通过 LDAP 对用户进行身份验证

python - 如何获取 numpy 函数 (ufunc) 参数