diff -r 5b253226cd36 Lib/smtplib.py --- a/Lib/smtplib.py Tue Apr 19 11:15:11 2011 -0700 +++ b/Lib/smtplib.py Wed Apr 20 11:53:57 2011 +0530 @@ -815,13 +815,22 @@ support). If host is not specified, '' (the local host) is used. If port is omitted, the standard SMTP-over-SSL port (465) is used. keyfile and certfile 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. context also optional, can contain + a SSLContext, and is an alternative to keyfile and certfile; If it is specified both + keyfile and certfile must be None. """ def __init__(self, host='', port=0, local_hostname=None, keyfile=None, certfile=None, - timeout=socket._GLOBAL_DEFAULT_TIMEOUT): + timeout=socket._GLOBAL_DEFAULT_TIMEOUT, context=None): + if context is not None and keyfile is not None: + raise ValueError("context and keyfile arguments are mutually " + "exclusive") + if context is not None and certfile is not None: + raise ValueError("context and certfile arguments are mutually " + "exclusive") self.keyfile = keyfile self.certfile = certfile + self.context = context SMTP.__init__(self, host, port, local_hostname, timeout) self.default_port = SMTP_SSL_PORT @@ -829,7 +838,10 @@ if self.debuglevel > 0: print('connect:', (host, port), file=stderr) new_socket = socket.create_connection((host, port), timeout) - new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile) + if self.context is not None: + new_socket = self.context.wrap_socket(new_socket) + else: + new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile) self.file = SSLFakeFile(new_socket) return new_socket diff -r 5b253226cd36 Misc/ACKS --- a/Misc/ACKS Tue Apr 19 11:15:11 2011 -0700 +++ b/Misc/ACKS Wed Apr 20 11:53:57 2011 +0530 @@ -366,6 +366,7 @@ Lance Finn Helsten Jonathan Hendry James Henstridge +Kasun Herath Chris Herborth Ivan Herman Jürgen Hermann