ZOHO smtp SMTPAuthenticationError at / (535, 'Authentication Failed') Django app

橙三吉。 提交于 2019-12-01 12:22:06

问题


I am trying to establish a connection via shell on the VPS with this code:

import smtplib
from email.mime.text import MIMEText


sender = 'my zoho email'
recipient = 'my gmail account email'


msg = MIMEText("Message text")
msg['Subject'] = "Sent from python"
msg['From'] = sender
msg['To'] = recipient


server = smtplib.SMTP_SSL('smtp.zoho.com', 465)

# Perform operations via server
server.login('my zoho account email', '*********')

All the credentials are correct, since I am login in successfully to my account at https://www.zoho.eu/mail/

When i try to login with:

server.login('my zoho account email', '*********')

I get SMTPAuthenticationError and the stack trace shows:

 self.connection.login(force_str(self.username), force_str(self.password)) 
 ...
 raise SMTPAuthenticationError(code, resp)

my settings.py is:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'     
EMAIL_USE_TSL = True
EMAIL_PORT = 465
EMAIL_HOST = 'smtp.zoho.com'
EMAIL_HOST_USER = '**********'
EMAIL_HOST_PASSWORD = '*********'

There are numerous threads about this on the web but, not even one has an answer about it. Their support doesn't answer for third day now...

I am using NGINX and the default configuration is not set for https:// but my custom configuration is and the website is running over https://.

Edit: If I try to connect over port 587 with:

server = smtplib.SMTP_SSL('smtp.zoho.com', 587)

I get:

SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

回答1:


Turns out I was registered under the European host of zoho so I fixed it by changing the EMAIL_HOST to 'smtp.zoho.eu'




回答2:


This is the only setting I have in settings.py and it is enough to get it working.

#Email Settings
EMAIL_USE_SSL = True
EMAIL_HOST = 'smtp.zoho.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'someone@example.com'
EMAIL_HOST_PASSWORD = 'yourpassword'
DEFAULT_FROM_EMAIL = 'someone@example.com'
SERVER_EMAIL = 'someone@example.com'

You can test it using the quick example from Django Docs.

from django.core.mail import send_mail

send_mail(
    'Subject here',
    'Here is the message.',
    'from@example.com',
    ['to@example.com'],
    fail_silently=False,
)



来源:https://stackoverflow.com/questions/45324416/zoho-smtp-smtpauthenticationerror-at-535-authentication-failed-django-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!