Show More
@@ -70,31 +70,27 b' class STARTTLS(smtplib.SMTP):' | |||
|
70 | 70 | self.does_esmtp = 0 |
|
71 | 71 | return (resp, reply) |
|
72 | 72 | |
|
73 | if util.safehasattr(smtplib.SMTP, '_get_socket'): | |
|
74 | class SMTPS(smtplib.SMTP): | |
|
75 | '''Derived class to verify the peer certificate for SMTPS. | |
|
76 | ||
|
77 | This class allows to pass any keyword arguments to SSL socket creation. | |
|
78 | ''' | |
|
79 | def __init__(self, sslkwargs, keyfile=None, certfile=None, **kwargs): | |
|
80 | self.keyfile = keyfile | |
|
81 | self.certfile = certfile | |
|
82 | smtplib.SMTP.__init__(self, **kwargs) | |
|
83 | self.default_port = smtplib.SMTP_SSL_PORT | |
|
84 | self._sslkwargs = sslkwargs | |
|
73 | class SMTPS(smtplib.SMTP): | |
|
74 | '''Derived class to verify the peer certificate for SMTPS. | |
|
85 | 75 |
|
|
86 | def _get_socket(self, host, port, timeout): | |
|
87 | if self.debuglevel > 0: | |
|
88 | print >> sys.stderr, 'connect:', (host, port) | |
|
89 | new_socket = socket.create_connection((host, port), timeout) | |
|
90 | new_socket = sslutil.wrapsocket(new_socket, | |
|
91 | self.keyfile, self.certfile, | |
|
92 | **self._sslkwargs) | |
|
93 | self.file = smtplib.SSLFakeFile(new_socket) | |
|
94 | return new_socket | |
|
95 | else: | |
|
96 | def SMTPS(sslkwargs, keyfile=None, certfile=None, **kwargs): | |
|
97 | raise error.Abort(_('SMTPS requires Python 2.6 or later')) | |
|
76 | This class allows to pass any keyword arguments to SSL socket creation. | |
|
77 | ''' | |
|
78 | def __init__(self, sslkwargs, keyfile=None, certfile=None, **kwargs): | |
|
79 | self.keyfile = keyfile | |
|
80 | self.certfile = certfile | |
|
81 | smtplib.SMTP.__init__(self, **kwargs) | |
|
82 | self.default_port = smtplib.SMTP_SSL_PORT | |
|
83 | self._sslkwargs = sslkwargs | |
|
84 | ||
|
85 | def _get_socket(self, host, port, timeout): | |
|
86 | if self.debuglevel > 0: | |
|
87 | print >> sys.stderr, 'connect:', (host, port) | |
|
88 | new_socket = socket.create_connection((host, port), timeout) | |
|
89 | new_socket = sslutil.wrapsocket(new_socket, | |
|
90 | self.keyfile, self.certfile, | |
|
91 | **self._sslkwargs) | |
|
92 | self.file = smtplib.SSLFakeFile(new_socket) | |
|
93 | return new_socket | |
|
98 | 94 | |
|
99 | 95 | def _smtp(ui): |
|
100 | 96 | '''build an smtp connection and return a function to send mail''' |
General Comments 0
You need to be logged in to leave comments.
Login now