From eeae4f86461e67868d398565eff7f4c5867451d6 Mon Sep 17 00:00:00 2001 From: sokumon Date: Mon, 30 Jun 2025 17:17:12 +0530 Subject: [PATCH] fix: handle abort while logout --- frappe/email/receive.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frappe/email/receive.py b/frappe/email/receive.py index e624d82a10..5907528f38 100644 --- a/frappe/email/receive.py +++ b/frappe/email/receive.py @@ -162,10 +162,14 @@ class EmailServer: return res[0] == "OK" # The folder exists TODO: handle other responses too def logout(self): - if cint(self.settings.use_imap): - self.imap.logout() - else: - self.pop.quit() + try: + if cint(self.settings.use_imap): + self.imap.logout() + else: + self.pop.quit() + except imaplib.IMAP4.abort: + self.connect() + self.logout() return def get_messages(self, folder="INBOX"):