Issue #11927: SMTP_SSL now uses port 465 by default as documented. Patch by Kasun Herath.

This commit is contained in:
Antoine Pitrou 2011-05-07 19:59:33 +02:00
parent 0639be6505
commit 21ce8f0d66
4 changed files with 15 additions and 2 deletions

View File

@ -222,6 +222,7 @@ class SMTP:
ehlo_msg = "ehlo" ehlo_msg = "ehlo"
ehlo_resp = None ehlo_resp = None
does_esmtp = 0 does_esmtp = 0
default_port = SMTP_PORT
def __init__(self, host='', port=0, local_hostname=None, def __init__(self, host='', port=0, local_hostname=None,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT): timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
@ -237,7 +238,6 @@ def __init__(self, host='', port=0, local_hostname=None,
""" """
self.timeout = timeout self.timeout = timeout
self.esmtp_features = {} self.esmtp_features = {}
self.default_port = SMTP_PORT
if host: if host:
(code, msg) = self.connect(host, port) (code, msg) = self.connect(host, port)
if code != 220: if code != 220:
@ -756,13 +756,15 @@ class SMTP_SSL(SMTP):
are also optional - they can contain a PEM formatted private key and are also optional - they can contain a PEM formatted private key and
certificate chain file for the SSL connection. certificate chain file for the SSL connection.
""" """
default_port = SMTP_SSL_PORT
def __init__(self, host='', port=0, local_hostname=None, def __init__(self, host='', port=0, local_hostname=None,
keyfile=None, certfile=None, keyfile=None, certfile=None,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT): timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
self.keyfile = keyfile self.keyfile = keyfile
self.certfile = certfile self.certfile = certfile
SMTP.__init__(self, host, port, local_hostname, timeout) SMTP.__init__(self, host, port, local_hostname, timeout)
self.default_port = SMTP_SSL_PORT
def _get_socket(self, host, port, timeout): def _get_socket(self, host, port, timeout):
if self.debuglevel > 0: if self.debuglevel > 0:

View File

@ -17,6 +17,13 @@ def test_connect(self):
server.ehlo() server.ehlo()
server.quit() 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(): def test_main():
test_support.run_unittest(SmtpSSLTest) test_support.run_unittest(SmtpSSLTest)

View File

@ -337,6 +337,7 @@ Malte Helmert
Lance Finn Helsten Lance Finn Helsten
Jonathan Hendry Jonathan Hendry
James Henstridge James Henstridge
Kasun Herath
Chris Herborth Chris Herborth
Ivan Herman Ivan Herman
Jürgen Hermann Jürgen Hermann

View File

@ -77,6 +77,9 @@ Core and Builtins
Library 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 - 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 detect mtime changes by comparing to the system clock instead of to the
previous value of the mtime. previous value of the mtime.