@@ -85,16 +85,17 @@ class IMAPClient(object):
85
85
"""A connection to the IMAP server specified by *host* is made when
86
86
this class is instantiated.
87
87
88
- *port* defaults to 143 , or 993 if *ssl* is ``True ``.
88
+ *port* defaults to 993 , or 143 if *ssl* is ``False ``.
89
89
90
90
If *use_uid* is ``True`` unique message UIDs be used for all calls
91
91
that accept message ids (defaults to ``True``).
92
92
93
- If *ssl* is ``True`` an SSL connection will be made (defaults to
94
- ``False``).
93
+ If *ssl* is ``True`` (the default) a secure connection will be made.
94
+ Otherwise an insecure connection over plain text will be
95
+ established.
95
96
96
97
If *ssl* is ``True`` the optional *ssl_context* argument can be
97
- used to provide a ``backports. ssl.SSLContext`` instance used to
98
+ used to provide an ``ssl.SSLContext`` instance used to
98
99
control SSL/TLS connection parameters. If this is not provided a
99
100
sensible default context will be used.
100
101
@@ -122,7 +123,7 @@ class IMAPClient(object):
122
123
AbortError = imaplib .IMAP4 .abort
123
124
ReadOnlyError = imaplib .IMAP4 .readonly
124
125
125
- def __init__ (self , host , port = None , use_uid = True , ssl = False , stream = False ,
126
+ def __init__ (self , host , port = None , use_uid = True , ssl = True , stream = False ,
126
127
ssl_context = None , timeout = None ):
127
128
if stream :
128
129
if port is not None :
@@ -132,6 +133,11 @@ def __init__(self, host, port=None, use_uid=True, ssl=False, stream=False,
132
133
elif port is None :
133
134
port = ssl and 993 or 143
134
135
136
+ if ssl and port == 143 :
137
+ logger .warning ("Attempting to establish an encrypted connection "
138
+ "to a port (143) often used for unencrypted "
139
+ "connections" )
140
+
135
141
self .host = host
136
142
self .port = port
137
143
self .ssl = ssl
@@ -146,7 +152,8 @@ def __init__(self, host, port=None, use_uid=True, ssl=False, stream=False,
146
152
self ._cached_capabilities = None
147
153
148
154
self ._imap = self ._create_IMAP4 ()
149
- logger .debug ("Connected to host %s" , self .host )
155
+ logger .debug ("Connected to host %s over %s" , self .host ,
156
+ "SSL/TLS" if ssl else "plain text" )
150
157
151
158
# Small hack to make imaplib log everything to its own logger
152
159
imaplib_logger = IMAPlibLoggerAdapter (
0 commit comments