Rajat Gupta
Rajat Gupta

Reputation: 41

Authentication failure using Zoho smtp with Django

I am trying to send email using my django app. But after setting Zoho account and adding necessary lines in settings.py I am still not able to send email and it keep giving SMTPAuthenticationError (535, b'Authentication Failed').

#settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.zoho.com'
EMAIL_HOST_USER = '[email protected]'
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',
'[email protected]',
['[email protected]'],
html_message=html
)
return render(request,'index.html')

enter image description here

Upvotes: 4

Views: 867

Answers (1)

mahoriR
mahoriR

Reputation: 4587

One of the reason could be 2-factor authentication being used in the zoho account. This prevents you from using account password, instead you need to generate application specific password and use the same. Read more here

Upvotes: 1

Related Questions