Authentication failure using Zoho smtp with Django

814 views Asked by At

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

1

There are 1 answers

0
mahoriR On

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