]> granicus.if.org Git - python/commitdiff
Issue #11927: SMTP_SSL now uses port 465 by default as documented. Patch by Kasun...
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 7 May 2011 17:39:37 +0000 (19:39 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 7 May 2011 17:39:37 +0000 (19:39 +0200)
Lib/smtplib.py
Lib/test/test_smtpnet.py
Misc/ACKS
Misc/NEWS

index a01a184c9f9c8eb723e188729ef9a08914c341cc..2c2141b167c631fabc9cb31725b9f20b54c837a9 100755 (executable)
@@ -219,6 +219,7 @@ class SMTP:
     ehlo_msg = "ehlo"
     ehlo_resp = None
     does_esmtp = 0
+    default_port = SMTP_PORT
 
     def __init__(self, host='', port=0, local_hostname=None,
                  timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
@@ -234,7 +235,6 @@ class SMTP:
         """
         self.timeout = timeout
         self.esmtp_features = {}
-        self.default_port = SMTP_PORT
         if host:
             (code, msg) = self.connect(host, port)
             if code != 220:
@@ -749,13 +749,15 @@ if _have_ssl:
         are also optional - they can contain a PEM formatted private key and
         certificate chain file for the SSL connection.
         """
+
+        default_port = SMTP_SSL_PORT
+
         def __init__(self, host='', port=0, local_hostname=None,
                      keyfile=None, certfile=None,
                      timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
             self.keyfile = keyfile
             self.certfile = certfile
             SMTP.__init__(self, host, port, local_hostname, timeout)
-            self.default_port = SMTP_SSL_PORT
 
         def _get_socket(self, host, port, timeout):
             if self.debuglevel > 0: print('connect:', (host, port), file=stderr)
index 6634df783bc59c0596c81e6a2b06592b7b0bc411..1571ca36f61525a2c9e8d0828a114e2bcc078382 100644 (file)
@@ -17,6 +17,13 @@ class SmtpSSLTest(unittest.TestCase):
         server.ehlo()
         server.quit()
 
+    def test_connect_default_port(self):
+        support.get_attribute(smtplib, 'SMTP_SSL')
+        with support.transient_internet(self.testServer):
+            server = smtplib.SMTP_SSL(self.testServer)
+        server.ehlo()
+        server.quit()
+
 def test_main():
     support.run_unittest(SmtpSSLTest)
 
index 59b36615391fb367b4102d2b2af5cb5e5f633f2f..80fda108c7b7570860113de2d192b09783b73fce 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -335,6 +335,7 @@ Malte Helmert
 Lance Finn Helsten
 Jonathan Hendry
 James Henstridge
+Kasun Herath
 Chris Herborth
 Ivan Herman
 Jürgen Hermann
index fddaf099c4ccb33a0079f87690dd2a5115aa7a50..4be61cf333255855b6fbcdcf5603d219f61aaf10 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -66,6 +66,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #11927: SMTP_SSL now uses port 465 by default as documented.  Patch
+  by Kasun Herath.
+
 - Issue 11999: fixed sporadic sync failure mailbox.Maildir due to its trying to
   detect mtime changes by comparing to the system clock instead of to the
   previous value of the mtime.