##// END OF EJS Templates
Catch smtp exceptions
Christian Ebert -
r5472:23889160 0.9.5 default
parent child Browse files
Show More
@@ -224,9 +224,8 b' def patchbomb(ui, repo, *revs, **opts):'
224 pass
224 pass
225 os.rmdir(tmpdir)
225 os.rmdir(tmpdir)
226
226
227 really_sending = not (opts['test'] or opts['mbox'])
227 if not (opts['test'] or opts['mbox']):
228
228 # really sending
229 if really_sending:
230 mail.validateconfig(ui)
229 mail.validateconfig(ui)
231
230
232 if not (revs or opts.get('rev') or opts.get('outgoing')):
231 if not (revs or opts.get('rev') or opts.get('outgoing')):
@@ -361,8 +360,6 b' def patchbomb(ui, repo, *revs, **opts):'
361
360
362 ui.write('\n')
361 ui.write('\n')
363
362
364 if really_sending:
365 mailer = mail.connect(ui)
366 parent = None
363 parent = None
367
364
368 sender_addr = email.Utils.parseaddr(sender)[1]
365 sender_addr = email.Utils.parseaddr(sender)[1]
@@ -411,7 +408,7 b' def patchbomb(ui, repo, *revs, **opts):'
411 ui.status('Sending ', m['Subject'], ' ...\n')
408 ui.status('Sending ', m['Subject'], ' ...\n')
412 # Exim does not remove the Bcc field
409 # Exim does not remove the Bcc field
413 del m['Bcc']
410 del m['Bcc']
414 mailer.sendmail(sender, to + bcc + cc, m.as_string(0))
411 mail.sendmail(ui, sender, to + bcc + cc, m.as_string(0))
415
412
416 cmdtable = {
413 cmdtable = {
417 "email":
414 "email":
@@ -67,7 +67,13 b' def connect(ui):'
67 return _sendmail(ui, method)
67 return _sendmail(ui, method)
68
68
69 def sendmail(ui, sender, recipients, msg):
69 def sendmail(ui, sender, recipients, msg):
70 return connect(ui).sendmail(sender, recipients, msg)
70 try:
71 return connect(ui).sendmail(sender, recipients, msg)
72 except smtplib.SMTPRecipientsRefused, inst:
73 recipients = [r[1] for r in inst.recipients.values()]
74 raise util.Abort('\n' + '\n'.join(recipients))
75 except smtplib.SMTPException, inst:
76 raise util.Abort(inst)
71
77
72 def validateconfig(ui):
78 def validateconfig(ui):
73 '''determine if we have enough config data to try sending email.'''
79 '''determine if we have enough config data to try sending email.'''
General Comments 0
You need to be logged in to leave comments. Login now