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
This commit is contained in:
Ankush Menat 2023-04-24 17:34:24 +05:30 committed by GitHub
parent 145ba36cea
commit eeda161e98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View file

@ -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,

View file

@ -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):