5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. |
6 # GNU General Public License version 2 or any later version. |
7 |
7 |
8 from i18n import _ |
8 from i18n import _ |
9 import util, encoding, sslutil |
9 import util, encoding, sslutil |
10 import os, smtplib, socket, quopri, time |
10 import os, smtplib, socket, quopri, time, sys |
11 import email.Header, email.MIMEText, email.Utils |
11 import email.Header, email.MIMEText, email.Utils |
12 |
12 |
13 _oldheaderinit = email.Header.Header.__init__ |
13 _oldheaderinit = email.Header.Header.__init__ |
14 def _unifiedheaderinit(self, *args, **kw): |
14 def _unifiedheaderinit(self, *args, **kw): |
15 """ |
15 """ |
70 self.default_port = smtplib.SMTP_SSL_PORT |
70 self.default_port = smtplib.SMTP_SSL_PORT |
71 self._sslkwargs = sslkwargs |
71 self._sslkwargs = sslkwargs |
72 |
72 |
73 def _get_socket(self, host, port, timeout): |
73 def _get_socket(self, host, port, timeout): |
74 if self.debuglevel > 0: |
74 if self.debuglevel > 0: |
75 print >> stderr, 'connect:', (host, port) |
75 print >> sys.stderr, 'connect:', (host, port) |
76 new_socket = socket.create_connection((host, port), timeout) |
76 new_socket = socket.create_connection((host, port), timeout) |
77 new_socket = sslutil.ssl_wrap_socket(new_socket, |
77 new_socket = sslutil.ssl_wrap_socket(new_socket, |
78 self.keyfile, self.certfile, |
78 self.keyfile, self.certfile, |
79 **self._sslkwargs) |
79 **self._sslkwargs) |
80 self.file = smtplib.SSLFakeFile(new_socket) |
80 self.file = smtplib.SSLFakeFile(new_socket) |