diff -r 47f37a688c4c Lib/smtplib.py --- a/Lib/smtplib.py Thu Mar 06 13:28:08 2014 -0600 +++ b/Lib/smtplib.py Mon Mar 10 02:21:13 2014 +0530 @@ -849,6 +849,11 @@ if self.sock: self.sock.close() self.sock = None + self.default_port = SMTP_PORT + self.ehlo_msg = "ehlo" + self.ehlo_resp = None + self.helo_resp = None + self.source_address = None def quit(self): """Terminate the SMTP session.""" diff -r 47f37a688c4c Lib/test/test_smtplib.py --- a/Lib/test/test_smtplib.py Thu Mar 06 13:28:08 2014 -0600 +++ b/Lib/test/test_smtplib.py Mon Mar 10 02:21:13 2014 +0530 @@ -522,6 +522,22 @@ smtp.send_message(m) smtp.close() + def testFlagResetOnQuit(self): + smtp = smtplib.SMTP(HOST, self.port) + smtp.connect() + smtp.default_port = 465 + smtp.ehlo_msg = "custom ehlo msg" + smtp.ehlo_resp = "custom ehlo resp" + smtp.helo_resp = "custom helo resp" + smtp.source_address = ('127.0.0.1',25) + smtp.quit() + self.assertEqual(smtp.default_port, 25) + self.assertEqual(smtp.ehlo_msg, "ehlo") + self.assertEqual(smtp.ehlo_resp, None) + self.assertEqual(smtp.helo_resp, None) + self.assertEqual(smtp.source_address, None) + + class NonConnectingTests(unittest.TestCase): def testNotConnected(self):