#8739: upgrade smtpd to RFC 5321 and 1870.

smtpd now handles EHLO and has infrastructure for extended smtp command mode.
The SIZE extension is also implemented.  In order to support parameters on
MAIL FROM, the RFC 5322 parser from the email package is used to parse the
address "token".

Logging subclasses things and overrides __init__, so it was necessary to
update those __init__ functions in the logging tests to make the logging tests
pass.

The original suggestion and patch were by Alberto Trevino.  Juhana Jauhiainen
added the --size argument and SIZE parameter support.  Michele OrrĂ¹ improved
the patch and added more tests.  Dan Boswell conditionalized various bits of
code on whether or not we are in HELO or EHLO mode, as well as some other
improvements and tests.  I finalized the patch and added the address parsing.
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 18dde2f..befc49e 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -229,13 +229,13 @@
 
     def testNOOP(self):
         smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
-        expected = (250, b'Ok')
+        expected = (250, b'OK')
         self.assertEqual(smtp.noop(), expected)
         smtp.quit()
 
     def testRSET(self):
         smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
-        expected = (250, b'Ok')
+        expected = (250, b'OK')
         self.assertEqual(smtp.rset(), expected)
         smtp.quit()
 
@@ -246,10 +246,18 @@
         self.assertEqual(smtp.ehlo(), expected)
         smtp.quit()
 
-    def testVRFY(self):
-        # VRFY isn't implemented in DebuggingServer
+    def testNotImplemented(self):
+        # EXPN isn't implemented in DebuggingServer
         smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
-        expected = (502, b'Error: command "VRFY" not implemented')
+        expected = (502, b'EXPN not implemented')
+        smtp.putcmd('EXPN')
+        self.assertEqual(smtp.getreply(), expected)
+        smtp.quit()
+
+    def testVRFY(self):
+        smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+        expected = (252, b'Cannot VRFY user, but will accept message ' + \
+                         b'and attempt delivery')
         self.assertEqual(smtp.vrfy('nobody@nowhere.com'), expected)
         self.assertEqual(smtp.verify('nobody@nowhere.com'), expected)
         smtp.quit()
@@ -265,7 +273,8 @@
 
     def testHELP(self):
         smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
-        self.assertEqual(smtp.help(), b'Error: command "HELP" not implemented')
+        self.assertEqual(smtp.help(), b'Supported commands: EHLO HELO MAIL ' + \
+                                      b'RCPT DATA RSET NOOP QUIT VRFY')
         smtp.quit()
 
     def testSend(self):