equal
deleted
inserted
replaced
104 if (starttls or smtps) and not util.safehasattr(socket, 'ssl'): |
104 if (starttls or smtps) and not util.safehasattr(socket, 'ssl'): |
105 raise error.Abort(_("can't use TLS: Python SSL support not installed")) |
105 raise error.Abort(_("can't use TLS: Python SSL support not installed")) |
106 mailhost = ui.config('smtp', 'host') |
106 mailhost = ui.config('smtp', 'host') |
107 if not mailhost: |
107 if not mailhost: |
108 raise error.Abort(_('smtp.host not configured - cannot send mail')) |
108 raise error.Abort(_('smtp.host not configured - cannot send mail')) |
109 verifycert = ui.config('smtp', 'verifycert', 'strict') |
|
110 if verifycert not in ['strict', 'loose']: |
|
111 if util.parsebool(verifycert) is not False: |
|
112 raise error.Abort(_('invalid smtp.verifycert configuration: %s') |
|
113 % (verifycert)) |
|
114 verifycert = False |
|
115 |
|
116 if smtps: |
109 if smtps: |
117 ui.note(_('(using smtps)\n')) |
110 ui.note(_('(using smtps)\n')) |
118 s = SMTPS(ui, local_hostname=local_hostname, host=mailhost) |
111 s = SMTPS(ui, local_hostname=local_hostname, host=mailhost) |
119 elif starttls: |
112 elif starttls: |
120 s = STARTTLS(ui, local_hostname=local_hostname, host=mailhost) |
113 s = STARTTLS(ui, local_hostname=local_hostname, host=mailhost) |
131 if starttls: |
124 if starttls: |
132 ui.note(_('(using starttls)\n')) |
125 ui.note(_('(using starttls)\n')) |
133 s.ehlo() |
126 s.ehlo() |
134 s.starttls() |
127 s.starttls() |
135 s.ehlo() |
128 s.ehlo() |
136 if (starttls or smtps) and verifycert: |
129 if starttls or smtps: |
137 ui.note(_('(verifying remote certificate)\n')) |
130 ui.note(_('(verifying remote certificate)\n')) |
138 sslutil.validatesocket(s.sock, verifycert == 'strict') |
131 sslutil.validatesocket(s.sock) |
139 username = ui.config('smtp', 'username') |
132 username = ui.config('smtp', 'username') |
140 password = ui.config('smtp', 'password') |
133 password = ui.config('smtp', 'password') |
141 if username and not password: |
134 if username and not password: |
142 password = ui.getpass() |
135 password = ui.getpass() |
143 if username and password: |
136 if username and password: |