使用Zoho smtp和Django进行身份验证失败

时间:2016-12-18 18:41:42

标签: python django authentication smtp smtplib

我正在尝试使用我的django应用发送电子邮件。但是在设置Zoho帐户并在settings.py中添加必要的行之后,我仍然无法发送电子邮件,并且它继续提供 SMTPAuthenticationError(535,b'身份验证失败')

#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

1 个答案:

答案 0 :(得分:0)

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