diff --git a/Doc/library/imaplib.rst b/Doc/library/imaplib.rst index f1344ae9bb0a49..0a3754ae5c9adc 100644 --- a/Doc/library/imaplib.rst +++ b/Doc/library/imaplib.rst @@ -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() @@ -638,4 +648,3 @@ retrieves and prints all messages:: print('Message %s\n%s\n' % (num, data[0][1])) M.close() M.logout() -