Show More
@@ -48,9 +48,10 b' class STARTTLS(smtplib.SMTP):' | |||||
48 |
|
48 | |||
49 | This class allows to pass any keyword arguments to SSL socket creation. |
|
49 | This class allows to pass any keyword arguments to SSL socket creation. | |
50 | ''' |
|
50 | ''' | |
51 | def __init__(self, sslkwargs, **kwargs): |
|
51 | def __init__(self, sslkwargs, host=None, **kwargs): | |
52 | smtplib.SMTP.__init__(self, **kwargs) |
|
52 | smtplib.SMTP.__init__(self, **kwargs) | |
53 | self._sslkwargs = sslkwargs |
|
53 | self._sslkwargs = sslkwargs | |
|
54 | self._host = host | |||
54 |
|
55 | |||
55 | def starttls(self, keyfile=None, certfile=None): |
|
56 | def starttls(self, keyfile=None, certfile=None): | |
56 | if not self.has_extn("starttls"): |
|
57 | if not self.has_extn("starttls"): | |
@@ -59,6 +60,7 b' class STARTTLS(smtplib.SMTP):' | |||||
59 | (resp, reply) = self.docmd("STARTTLS") |
|
60 | (resp, reply) = self.docmd("STARTTLS") | |
60 | if resp == 220: |
|
61 | if resp == 220: | |
61 | self.sock = sslutil.wrapsocket(self.sock, keyfile, certfile, |
|
62 | self.sock = sslutil.wrapsocket(self.sock, keyfile, certfile, | |
|
63 | serverhostname=self._host, | |||
62 | **self._sslkwargs) |
|
64 | **self._sslkwargs) | |
63 | self.file = smtplib.SSLFakeFile(self.sock) |
|
65 | self.file = smtplib.SSLFakeFile(self.sock) | |
64 | self.helo_resp = None |
|
66 | self.helo_resp = None | |
@@ -72,10 +74,12 b' class SMTPS(smtplib.SMTP):' | |||||
72 |
|
74 | |||
73 | This class allows to pass any keyword arguments to SSL socket creation. |
|
75 | This class allows to pass any keyword arguments to SSL socket creation. | |
74 | ''' |
|
76 | ''' | |
75 |
def __init__(self, sslkwargs, keyfile=None, certfile=None, |
|
77 | def __init__(self, sslkwargs, keyfile=None, certfile=None, host=None, | |
|
78 | **kwargs): | |||
76 | self.keyfile = keyfile |
|
79 | self.keyfile = keyfile | |
77 | self.certfile = certfile |
|
80 | self.certfile = certfile | |
78 | smtplib.SMTP.__init__(self, **kwargs) |
|
81 | smtplib.SMTP.__init__(self, **kwargs) | |
|
82 | self._host = host | |||
79 | self.default_port = smtplib.SMTP_SSL_PORT |
|
83 | self.default_port = smtplib.SMTP_SSL_PORT | |
80 | self._sslkwargs = sslkwargs |
|
84 | self._sslkwargs = sslkwargs | |
81 |
|
85 | |||
@@ -85,6 +89,7 b' class SMTPS(smtplib.SMTP):' | |||||
85 | new_socket = socket.create_connection((host, port), timeout) |
|
89 | new_socket = socket.create_connection((host, port), timeout) | |
86 | new_socket = sslutil.wrapsocket(new_socket, |
|
90 | new_socket = sslutil.wrapsocket(new_socket, | |
87 | self.keyfile, self.certfile, |
|
91 | self.keyfile, self.certfile, | |
|
92 | serverhostname=self._host, | |||
88 | **self._sslkwargs) |
|
93 | **self._sslkwargs) | |
89 | self.file = smtplib.SSLFakeFile(new_socket) |
|
94 | self.file = smtplib.SSLFakeFile(new_socket) | |
90 | return new_socket |
|
95 | return new_socket | |
@@ -114,9 +119,9 b' def _smtp(ui):' | |||||
114 | sslkwargs = {'ui': ui} |
|
119 | sslkwargs = {'ui': ui} | |
115 | if smtps: |
|
120 | if smtps: | |
116 | ui.note(_('(using smtps)\n')) |
|
121 | ui.note(_('(using smtps)\n')) | |
117 | s = SMTPS(sslkwargs, local_hostname=local_hostname) |
|
122 | s = SMTPS(sslkwargs, local_hostname=local_hostname, host=mailhost) | |
118 | elif starttls: |
|
123 | elif starttls: | |
119 | s = STARTTLS(sslkwargs, local_hostname=local_hostname) |
|
124 | s = STARTTLS(sslkwargs, local_hostname=local_hostname, host=mailhost) | |
120 | else: |
|
125 | else: | |
121 | s = smtplib.SMTP(local_hostname=local_hostname) |
|
126 | s = smtplib.SMTP(local_hostname=local_hostname) | |
122 | if smtps: |
|
127 | if smtps: |
General Comments 0
You need to be logged in to leave comments.
Login now