diff options
Diffstat (limited to 'Lib')
| -rwxr-xr-x | Lib/smtplib.py | 4 | ||||
| -rw-r--r-- | Lib/test/test_smtplib.py | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 759b77e..09b4ea6 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -866,6 +866,10 @@ class SMTP: 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 --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index 16e90f4..95a9dbe 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -858,6 +858,21 @@ class SMTPSimTests(unittest.TestCase): self.assertIn(sim_auth_login_password, str(err)) smtp.close() + def test_quit_resets_greeting(self): + smtp = smtplib.SMTP(HOST, self.port, + local_hostname='localhost', + timeout=15) + code, message = smtp.ehlo() + self.assertEqual(code, 250) + self.assertIn('size', smtp.esmtp_features) + smtp.quit() + self.assertNotIn('size', smtp.esmtp_features) + smtp.connect(HOST, self.port) + 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() |
