Skip to content
13 changes: 11 additions & 2 deletions Doc/library/imaplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,19 @@ An :class:`IMAP4` instance has the following methods:
that will be base64 encoded and sent to the server. It should return
``None`` if the client abort response ``*`` should be sent instead.

Example of a SASL PLAIN *authobject*::

def plain_auth(data):
user = input('User: ')
password = getpass.getpass()
return f'{user}\x00{user}\x00{password}'

M.authenticate('PLAIN', plain_auth)

.. versionchanged:: 3.5
string usernames and passwords are now encoded to ``utf-8`` instead of
being limited to ASCII.
being limited to ASCII. :meth:`authenticate` is the only standard way
to use ``utf-8`` credentials on an ``IMAP4rev1`` server.


.. method:: IMAP4.check()
Expand Down Expand Up @@ -638,4 +648,3 @@ retrieves and prints all messages::
print('Message %s\n%s\n' % (num, data[0][1]))
M.close()
M.logout()