##// END OF EJS Templates
smtp: fix for server doesn't support starttls extension...
Zhigang Wang -
r13201:f0525057 default
parent child Browse files
Show More
@@ -709,8 +709,8 b' Configuration for extensions that need t'
709 709 ``port``
710 710 Optional. Port to connect to on mail server. Default: 25.
711 711 ``tls``
712 Optional. Whether to connect to mail server using TLS. True or
713 False. Default: False.
712 Optional. Method to enable TLS when connecting to mail server: starttls,
713 smtps or none. Default: none.
714 714 ``username``
715 715 Optional. User name for authenticating with the SMTP server.
716 716 Default: none.
@@ -33,6 +33,16 b" email.Header.Header.__dict__['__init__']"
33 33 def _smtp(ui):
34 34 '''build an smtp connection and return a function to send mail'''
35 35 local_hostname = ui.config('smtp', 'local_hostname')
36 tls = ui.config('smtp', 'tls')
37 # backward compatible: when tls = true, we use starttls.
38 starttls = tls == 'starttls' or util.parsebool(tls)
39 smtps = tls == 'smtps'
40 if (starttls or smtps) and not hasattr(socket, 'ssl'):
41 raise util.Abort(_("can't use TLS: Python SSL support not installed"))
42 if smtps:
43 ui.note(_('(using smtps)\n'))
44 s = smtplib.SMTP_SSL(local_hostname=local_hostname)
45 else:
36 46 s = smtplib.SMTP(local_hostname=local_hostname)
37 47 mailhost = ui.config('smtp', 'host')
38 48 if not mailhost:
@@ -41,11 +51,8 b' def _smtp(ui):'
41 51 ui.note(_('sending mail: smtp host %s, port %s\n') %
42 52 (mailhost, mailport))
43 53 s.connect(host=mailhost, port=mailport)
44 if ui.configbool('smtp', 'tls'):
45 if not hasattr(socket, 'ssl'):
46 raise util.Abort(_("can't use TLS: Python SSL support "
47 "not installed"))
48 ui.note(_('(using tls)\n'))
54 if starttls:
55 ui.note(_('(using starttls)\n'))
49 56 s.ehlo()
50 57 s.starttls()
51 58 s.ehlo()
General Comments 0
You need to be logged in to leave comments. Login now