Show More
@@ -82,6 +82,15 class SMTPS(smtplib.SMTP): | |||||
82 | self.file = smtplib.SSLFakeFile(new_socket) |
|
82 | self.file = smtplib.SSLFakeFile(new_socket) | |
83 | return new_socket |
|
83 | return new_socket | |
84 |
|
84 | |||
|
85 | def _pyhastls(): | |||
|
86 | """Returns true iff Python has TLS support, false otherwise.""" | |||
|
87 | try: | |||
|
88 | import ssl | |||
|
89 | getattr(ssl, 'HAS_TLS', False) | |||
|
90 | return True | |||
|
91 | except ImportError: | |||
|
92 | return False | |||
|
93 | ||||
85 | def _smtp(ui): |
|
94 | def _smtp(ui): | |
86 | '''build an smtp connection and return a function to send mail''' |
|
95 | '''build an smtp connection and return a function to send mail''' | |
87 | local_hostname = ui.config('smtp', 'local_hostname') |
|
96 | local_hostname = ui.config('smtp', 'local_hostname') | |
@@ -89,7 +98,7 def _smtp(ui): | |||||
89 | # backward compatible: when tls = true, we use starttls. |
|
98 | # backward compatible: when tls = true, we use starttls. | |
90 | starttls = tls == 'starttls' or stringutil.parsebool(tls) |
|
99 | starttls = tls == 'starttls' or stringutil.parsebool(tls) | |
91 | smtps = tls == 'smtps' |
|
100 | smtps = tls == 'smtps' | |
92 |
if (starttls or smtps) and not |
|
101 | if (starttls or smtps) and not _pyhastls(): | |
93 | raise error.Abort(_("can't use TLS: Python SSL support not installed")) |
|
102 | raise error.Abort(_("can't use TLS: Python SSL support not installed")) | |
94 | mailhost = ui.config('smtp', 'host') |
|
103 | mailhost = ui.config('smtp', 'host') | |
95 | if not mailhost: |
|
104 | if not mailhost: |
General Comments 0
You need to be logged in to leave comments.
Login now