Email providers throw all kinds of garbage in their emails - even Gmail and Thunderbird send invalid UTF-8 in certain cases. Not throwing UnicodeErrors every time an email provider screws up their UTF-8 would really help QOL when using this library.
The new ImapTransport parameter ssl_context replaces the usesslcontext
parameter and allows the user to supply their own ssl context object. If
ssl_context is not given, but ssl is true, python's default ssl context
is used. That default context is the one that actually does some
certificate checks, such as whether the hostname matches the names given
in the server's certificate and not the default context used by
IMAP4_SSL when instantiated with ssl_context=None which does not
certificate checks at all.
The Imbox class is extended with the same ssl_context parameter which is
simply passed through to ImapTransport.
This commit together with the previous commits from Dustin Demuth
changes Imbox in a slightly incompatible way: SSL-Certificates are now
checked by default whereas before they were not checked at all. This
improves security substantially but users need to be aware that working
programs might start raising exceptions due to failing certificate
checks.
This reverts the approach to IMAP transport instantiation back to how it
was done prior to 2a0117b6 which introduced the usesslcontext parameter.
This reduces code duplication and importantly make instantiation work
again because self.IMAP4 and self.IMAP4_SSL do not exist.
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