According to https://github.com/martinrusev/imbox/issues/68 the
software was altered, in order to use the systems SSL-Context as default. It allows to toggle the use of the SSL-Default Context. It does not allow to use a custom context. Considerations: * If No SSL-Validation should be done, the ImboxClass should be adapted, in order to achieve configuration of the ssl-context. This commit does not contain this alteration. Other Changes: * Reformatted long lines
This commit is contained in:
@@ -1,25 +1,34 @@
|
||||
from imaplib import IMAP4, IMAP4_SSL
|
||||
|
||||
import logging
|
||||
import ssl as pythonssllib
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ImapTransport(object):
|
||||
|
||||
def __init__(self, hostname, port=None, ssl=False):
|
||||
def __init__(self, hostname, port=None, ssl=True, usesslcontext=True):
|
||||
self.hostname = hostname
|
||||
self.port = port
|
||||
|
||||
if ssl:
|
||||
self.transport = IMAP4_SSL
|
||||
if usesslcontext = True:
|
||||
context = pythonssllib.create_default_context()
|
||||
else:
|
||||
context = None
|
||||
|
||||
if not self.port:
|
||||
self.port = 993
|
||||
self.server = self.IMAP4_SSL(self.hostname, self.port,
|
||||
ssl_context=context)
|
||||
else:
|
||||
self.transport = IMAP4
|
||||
if not self.port:
|
||||
self.port = 143
|
||||
|
||||
self.server = self.transport(self.hostname, self.port)
|
||||
logger.debug("Created IMAP4 transport for {host}:{port}".format(host=self.hostname, port=self.port))
|
||||
self.server = self.IMAP4(self.hostname, self.port)
|
||||
logger.debug("Created IMAP4 transport for {host}:{port}"
|
||||
.format(host=self.hostname, port=self.port))
|
||||
|
||||
def list_folders(self):
|
||||
logger.debug("List all folders in mailbox")
|
||||
@@ -28,5 +37,6 @@ class ImapTransport(object):
|
||||
def connect(self, username, password):
|
||||
self.server.login(username, password)
|
||||
self.server.select()
|
||||
logger.debug("Logged into server {} and selected mailbox 'INBOX'".format(self.hostname))
|
||||
logger.debug("Logged into server {} and selected mailbox 'INBOX'"
|
||||
.format(self.hostname))
|
||||
return self.server
|
||||
|
||||
Reference in New Issue
Block a user