summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-05-07 17:59:33 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-05-07 17:59:33 (GMT)
commit21ce8f0d662df360e7a65a544309563fecd67f08 (patch)
tree7e66e87c18e1a35b446408328bd08da198a187c2 /Lib
parent0639be650511f717399e803faa798257b790ae81 (diff)
downloadcpython-21ce8f0d662df360e7a65a544309563fecd67f08.zip
cpython-21ce8f0d662df360e7a65a544309563fecd67f08.tar.gz
cpython-21ce8f0d662df360e7a65a544309563fecd67f08.tar.bz2
Issue #11927: SMTP_SSL now uses port 465 by default as documented. Patch by Kasun Herath.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/smtplib.py6
-rw-r--r--Lib/test/test_smtpnet.py7
2 files changed, 11 insertions, 2 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index e7d3786..e3ffb37 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -222,6 +222,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):
@@ -237,7 +238,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:
@@ -756,13 +756,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:
diff --git a/Lib/test/test_smtpnet.py b/Lib/test/test_smtpnet.py
index f25343d..2dc39eb 100644
--- a/Lib/test/test_smtpnet.py
+++ b/Lib/test/test_smtpnet.py
@@ -17,6 +17,13 @@ class SmtpSSLTest(unittest.TestCase):
server.ehlo()
server.quit()
+ def test_connect_default_port(self):
+ test_support.get_attribute(smtplib, 'SMTP_SSL')
+ with test_support.transient_internet(self.testServer):
+ server = smtplib.SMTP_SSL(self.testServer)
+ server.ehlo()
+ server.quit()
+
def test_main():
test_support.run_unittest(SmtpSSLTest)