From ea79dc6f40c8710814630540cd72ecb8b3f7c3b3 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 24 Aug 2015 13:36:35 +0530 Subject: [PATCH] [fix] catch specific smtp exceptions in bulk flush for future retry --- frappe/email/bulk.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frappe/email/bulk.py b/frappe/email/bulk.py index 5b88bd23e9..c5ed6e7ca3 100644 --- a/frappe/email/bulk.py +++ b/frappe/email/bulk.py @@ -216,11 +216,18 @@ def flush(from_test=False): frappe.db.sql("""update `tabBulk Email` set status='Sent' where name=%s""", (email["name"],), auto_commit=auto_commit) - except smtplib.SMTPException: + except (smtplib.SMTPServerDisconnected, + smtplib.SMTPConnectError, + smtplib.SMTPHeloError, + smtplib.SMTPAuthenticationError): + # bad connection, retry later frappe.db.sql("""update `tabBulk Email` set status='Not Sent' where name=%s""", (email["name"],), auto_commit=auto_commit) + # no need to attempt further + return + except Exception, e: frappe.db.sql("""update `tabBulk Email` set status='Error', error=%s where name=%s""", (unicode(e), email["name"]), auto_commit=auto_commit)