From b715e4d426f598694d50b46e3e60108d24649eda Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Thu, 27 Jul 2023 15:07:59 -0700 Subject: [PATCH] Creates and provides a default SSL context to the IMAP library --- src/paperless_mail/mail.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index 65768d3c2..a0bda19ba 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -2,6 +2,7 @@ import datetime import itertools import logging import os +import ssl import tempfile import traceback from datetime import date @@ -394,13 +395,12 @@ def get_mailbox(server, port, security) -> MailBox: """ Returns the correct MailBox instance for the given configuration. """ - if security == MailAccount.ImapSecurity.NONE: mailbox = MailBoxUnencrypted(server, port) elif security == MailAccount.ImapSecurity.STARTTLS: - mailbox = MailBoxTls(server, port) + mailbox = MailBoxTls(server, port, ssl_context=ssl.create_default_context()) elif security == MailAccount.ImapSecurity.SSL: - mailbox = MailBox(server, port) + mailbox = MailBox(server, port, ssl_context=ssl.create_default_context()) else: raise NotImplementedError("Unknown IMAP security") # pragma: nocover return mailbox