Shutdown IMAP connection when done with it.

This commit is contained in:
Jim Miller 2025-06-10 17:42:07 -05:00
parent 637c6e3cc3
commit 921f8c287b

View file

@ -193,6 +193,7 @@ def get_urls_from_imap(srv,user,passwd,folder,markread=True,normalize_urls=False
# logger.debug("get_urls_from_imap srv:(%s)"%srv) # logger.debug("get_urls_from_imap srv:(%s)"%srv)
mail = imaplib.IMAP4_SSL(srv) mail = imaplib.IMAP4_SSL(srv)
try:
status = mail.login(user, passwd) status = mail.login(user, passwd)
if status[0] != 'OK': if status[0] != 'OK':
raise FetchEmailFailed("Failed to login to mail server") raise FetchEmailFailed("Failed to login to mail server")
@ -277,6 +278,8 @@ def get_urls_from_imap(srv,user,passwd,folder,markread=True,normalize_urls=False
[ urls.add(x) for x in urllist ] [ urls.add(x) for x in urllist ]
return urls return urls
finally:
mail.shutdown()
# used by drag-n-drop of email from thunderbird onto Calibre. # used by drag-n-drop of email from thunderbird onto Calibre.
def get_urls_from_mime(mime_data): def get_urls_from_mime(mime_data):