[BangPypers] smtlib.SMTP connection unexpectedly closed.

Jins Thomas jinsthomas at gmail.com
Wed Jul 5 04:54:32 EDT 2017


Hi all,

Was trying a small code to send email from a server

import smtplib

server = smtplib.SMTP('125.x.x.x.', 465)
server.starttls()
server.login("test at xx.com", "xxxx")

msg = "TEST MAIL!"
server.sendmail("test at xx.com", "test at xx.com", msg)
server.quit()

But getting failed with following error. Couldn't debug the reason why it's
happening.

Traceback (most recent call last):
  File "test_email.py", line 3, in <module>
    server = smtplib.SMTP('125.x.x.x', 465)
  File "/usr/local/lib/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/local/lib/python2.7/smtplib.py", line 317, in connect
    (code, msg) = self.getreply()
  File "/usr/local/lib/python2.7/smtplib.py", line 368, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed

Would like to know your thoughts


More information about the BangPypers mailing list