Show More
@@ -151,20 +151,9 b' def _smtp(ui):' | |||
|
151 | 151 | if starttls or smtps: |
|
152 | 152 | ui.note(_(b'(verifying remote certificate)\n')) |
|
153 | 153 | sslutil.validatesocket(s.sock) |
|
154 | username = ui.config(b'smtp', b'username') | |
|
155 | password = ui.config(b'smtp', b'password') | |
|
156 | if username: | |
|
157 | if password: | |
|
158 | password = encoding.strfromlocal(password) | |
|
159 | else: | |
|
160 | password = ui.getpass() | |
|
161 | if password is not None: | |
|
162 | password = encoding.strfromlocal(password) | |
|
163 | if username and password: | |
|
164 | ui.note(_(b'(authenticating to mail server as %s)\n') % username) | |
|
165 | username = encoding.strfromlocal(username) | |
|
154 | ||
|
166 | 155 |
|
|
167 | s.login(username, password) | |
|
156 | _smtp_login(ui, s, mailhost, mailport) | |
|
168 | 157 |
|
|
169 | 158 |
|
|
170 | 159 | |
@@ -180,6 +169,29 b' def _smtp(ui):' | |||
|
180 | 169 | return send |
|
181 | 170 | |
|
182 | 171 | |
|
172 | def _smtp_login(ui, smtp, mailhost, mailport): | |
|
173 | """A hook for the keyring extension to perform the actual SMTP login. | |
|
174 | ||
|
175 | An already connected SMTP object of the proper type is provided, based on | |
|
176 | the current configuration. The host and port to which the connection was | |
|
177 | established are provided for accessibility, since the SMTP object doesn't | |
|
178 | provide an accessor. ``smtplib.SMTPException`` is raised on error. | |
|
179 | """ | |
|
180 | username = ui.config(b'smtp', b'username') | |
|
181 | password = ui.config(b'smtp', b'password') | |
|
182 | if username: | |
|
183 | if password: | |
|
184 | password = encoding.strfromlocal(password) | |
|
185 | else: | |
|
186 | password = ui.getpass() | |
|
187 | if password is not None: | |
|
188 | password = encoding.strfromlocal(password) | |
|
189 | if username and password: | |
|
190 | ui.note(_(b'(authenticating to mail server as %s)\n') % username) | |
|
191 | username = encoding.strfromlocal(username) | |
|
192 | smtp.login(username, password) | |
|
193 | ||
|
194 | ||
|
183 | 195 | def _sendmail(ui, sender, recipients, msg): |
|
184 | 196 | '''send mail using sendmail.''' |
|
185 | 197 | program = ui.config(b'email', b'method') |
General Comments 0
You need to be logged in to leave comments.
Login now