mirror of
https://github.com/JonathanHerrewijnen/calibre-web.git
synced 2024-11-11 05:33:57 +00:00
Fix for #587 (Better handling of errors in sending email)
This commit is contained in:
parent
c3b0492834
commit
4dd6c55c38
@ -403,7 +403,7 @@ class WorkerThread(threading.Thread):
|
||||
msg['To'] = obj['recipent']
|
||||
|
||||
use_ssl = int(obj['settings'].get('mail_use_ssl', 0))
|
||||
|
||||
try:
|
||||
# convert MIME message to string
|
||||
fp = StringIO()
|
||||
gen = Generator(fp, mangle_from_=False)
|
||||
@ -411,7 +411,6 @@ class WorkerThread(threading.Thread):
|
||||
msg = fp.getvalue()
|
||||
|
||||
# send email
|
||||
try:
|
||||
timeout = 600 # set timeout to 5mins
|
||||
|
||||
org_stderr = sys.stderr
|
||||
@ -441,9 +440,17 @@ class WorkerThread(threading.Thread):
|
||||
|
||||
sys.stderr = org_stderr
|
||||
|
||||
except (socket.error, smtplib.SMTPRecipientsRefused, smtplib.SMTPException) as e:
|
||||
self._handleError(e)
|
||||
except (MemoryError) as e:
|
||||
self._handleError(u'Error sending email: ' + e.message)
|
||||
return None
|
||||
except (smtplib.SMTPException) as e:
|
||||
self._handleError(u'Error sending email: ' + e.smtp_error.replace("\n",'. '))
|
||||
return None
|
||||
except (socket.error) as e:
|
||||
self._handleError(u'Error sending email: ' + e.strerror)
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def _formatRuntime(self, runtime):
|
||||
self.UIqueue[self.current]['rt'] = runtime.total_seconds()
|
||||
|
Loading…
Reference in New Issue
Block a user