From 0d11be007609c40e3aa2afde84021b0bc1ed848a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 5 Jun 2015 15:15:00 +0530 Subject: [PATCH] Use a safe logger when sending email --- src/calibre/gui2/email.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/email.py b/src/calibre/gui2/email.py index b3cebffaae..1f6fd44aed 100644 --- a/src/calibre/gui2/email.py +++ b/src/calibre/gui2/email.py @@ -115,13 +115,19 @@ class Sendmail(object): eto = [] for x in to.split(','): eto.append(extract_email_address(x.strip())) + def safe_debug(*args, **kwargs): + try: + return log.debug(*args, **kwargs) + except Exception: + pass + sendmail(msg, efrom, eto, localhost=None, verbose=1, relay=opts.relay_host, username=opts.relay_username, password=unhexlify(opts.relay_password).decode('utf-8'), port=opts.relay_port, encryption=opts.encryption, - debug_output=log.debug) + debug_output=safe_debug) finally: self.last_send_time = time.time()