Casey added the comment:
Update: After digging further (and enabling the "Less secure app access"
setting on the test Google account) it looks like Python 2.7 caps TLS at 1.2
rather than using 1.3 when OpenSSL is upgraded. This prevents breakage, and it
looks like the SSLSocket class silence
New submission from Casey :
OpenSSL 1.1.1 is an LTS release that will see long maintenance, and Ubuntu
18.04 LTS has now upgraded from 1.1.0 to 1.1.1. However, with this upgrade, TLS
1.3 allows email clients to require an SNI for the handshake to succeed.
Because the 2.7 imap module does not