From eeda161e98a73f67c0787f4fd92bc17e0d6d9356 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 24 Apr 2023 17:34:24 +0530 Subject: [PATCH] fix: handle `SMTPRecipientsRefused` retries (#20819) * fix: remove trailing and leading quotes from email * chore: typo * fix: dont retry `SMTPRecipientsRefused` If refused once it's unlikely to work again just by retrying. There's no mechanism to prevent infinite retry. This will still attempt for MAX_RETRY_COUNT. * Revert "fix: remove trailing and leading quotes from email" This reverts commit 2676ac2c7fe76c34049da05a209554fee6b3d911. refer https://github.com/frappe/frappe/pull/20819#discussion_r1175166987 --- frappe/email/doctype/email_queue/email_queue.py | 3 +-- .../doctype/email_queue_recipient/email_queue_recipient.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/frappe/email/doctype/email_queue/email_queue.py b/frappe/email/doctype/email_queue/email_queue.py index c10494b0d9..d254c87a0a 100644 --- a/frappe/email/doctype/email_queue/email_queue.py +++ b/frappe/email/doctype/email_queue/email_queue.py @@ -203,7 +203,7 @@ class SendMailContext: # Note: smtp session will have to be manually closed self.retain_smtp_session = bool(smtp_server_instance) - self.sent_to = [rec.recipient for rec in self.queue_doc.recipients if rec.is_main_sent()] + self.sent_to = [rec.recipient for rec in self.queue_doc.recipients if rec.is_mail_sent()] def __enter__(self): self.queue_doc.update_status(status="Sending", commit=True) @@ -213,7 +213,6 @@ class SendMailContext: exceptions = [ smtplib.SMTPServerDisconnected, smtplib.SMTPAuthenticationError, - smtplib.SMTPRecipientsRefused, smtplib.SMTPConnectError, smtplib.SMTPHeloError, JobTimeoutException, diff --git a/frappe/email/doctype/email_queue_recipient/email_queue_recipient.py b/frappe/email/doctype/email_queue_recipient/email_queue_recipient.py index bcb8d9b05d..705075a862 100644 --- a/frappe/email/doctype/email_queue_recipient/email_queue_recipient.py +++ b/frappe/email/doctype/email_queue_recipient/email_queue_recipient.py @@ -11,7 +11,7 @@ class EmailQueueRecipient(Document): def is_mail_to_be_sent(self): return self.status == "Not Sent" - def is_main_sent(self): + def is_mail_sent(self): return self.status == "Sent" def update_db(self, commit=False, **kwargs):