Connection unexpectedly closed Error while using SMTPLib
This is the code fragment that I am trying to use
- import smtplib
- import sys
- sender = 'username@datamattic.com'
- receivers = ['uname@gmail.com','username@datamattic.com']
- message = """From: From Person <from@fromdomain.com>
To: To Person <to@todomain.com>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
- try:
- smtpObj = smtplib.SMTP_SSL('smtp.zoho.com',465)
- smtpObj.login('username@datamattic.com','SamplePassword')
- smtpObj.sendmail(sender, receivers, message)
- print "Successfully sent email"
- smtpObj.quit()
- except Exception, exc:
- sys.exit( "mail failed; %s" % str(exc) ) # give a error message
Upon execution, it always fails with the rror message "Connection unexpectedly closed". Am I missing something? I was earlier getting authentication failure messages following which I disabled two factor authentication on my account.