--- smtplib.py.orig 2017-05-17 16:48:56.993030185 -0600 +++ smtplib.py 2017-05-17 16:55:09.564272075 -0600 @@ -250,6 +250,7 @@ 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