close

[Solved] Python 2: SMTPServerDisconnected: Connection unexpectedly closed

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Python 2: SMTPServerDisconnected: Connection unexpectedly closed in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Python 2: SMTPServerDisconnected: Connection unexpectedly closed Error Occurs?

Today I get the following error Python 2: SMTPServerDisconnected: Connection unexpectedly closed in python.

How To Solve Python 2: SMTPServerDisconnected: Connection unexpectedly closed Error ?

  1. How To Solve Python 2: SMTPServerDisconnected: Connection unexpectedly closed Error ?

    To Solve Python 2: SMTPServerDisconnected: Connection unexpectedly closed ErrorUsing smtplib.SMTP_SSL() instead of smtplib.SMTP() works for me. Try this.

  2. Python 2: SMTPServerDisconnected: Connection unexpectedly closed

    To Solve Python 2: SMTPServerDisconnected: Connection unexpectedly closed ErrorUsing smtplib.SMTP_SSL() instead of smtplib.SMTP() works for me. Try this.

Solution 1


I Had the same issue and solved it just by specifying the right port like this:

smtplib.SMTP('smtp.gmail.com', 587)

Solution 2

Using smtplib.SMTP_SSL() instead of smtplib.SMTP() works for me. Try this.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read