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