summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLib/smtplib.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index f7c2c77ab4..5e422b704a 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -250,6 +250,7 @@ class SMTP:
if host:
(code, msg) = self.connect(host, port)
if code != 220:
+ self.close()
raise SMTPConnectError(code, msg)
if local_hostname is not None:
self.local_hostname = local_hostname