diff -r f44f5daff665 Lib/smtplib.py --- a/Lib/smtplib.py Sun Aug 17 15:32:42 2014 +0300 +++ b/Lib/smtplib.py Sun Aug 17 18:52:43 2014 +0200 @@ -891,6 +891,10 @@ def quit(self): """Terminate the SMTP session.""" res = self.docmd("quit") + # A new EHLO is required after reconnecting with connect() + self.ehlo_resp = self.helo_resp = None + self.esmtp_features = {} + self.does_esmtp = False self.close() return res diff -r f44f5daff665 Lib/test/test_smtplib.py --- a/Lib/test/test_smtplib.py Sun Aug 17 15:32:42 2014 +0300 +++ b/Lib/test/test_smtplib.py Sun Aug 17 18:52:43 2014 +0200 @@ -876,6 +876,21 @@ str(err)) smtp.close() + def test_quit_resets_greeting(self): + args = HOST, self.port + kwargs = {'local_hostname': 'localhost', 'timeout': 15} + smtp = smtplib.SMTP(*args, **kwargs) + code, message = smtp.ehlo() + self.assertEqual(code, 250) + self.assertIn('size', smtp.esmtp_features) + smtp.quit() + self.assertNotIn('size', smtp.esmtp_features) + smtp.connect(*args) + self.assertNotIn('size', smtp.esmtp_features) + smtp.ehlo_or_helo_if_needed() + self.assertIn('size', smtp.esmtp_features) + smtp.quit() + def test_with_statement(self): with smtplib.SMTP(HOST, self.port) as smtp: code, message = smtp.noop()