summaryrefslogtreecommitdiffstats
path: root/Doc/library/imaplib.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/imaplib.rst')
-rw-r--r--Doc/library/imaplib.rst43
1 files changed, 41 insertions, 2 deletions
diff --git a/Doc/library/imaplib.rst b/Doc/library/imaplib.rst
index fa736fe..15b0932 100644
--- a/Doc/library/imaplib.rst
+++ b/Doc/library/imaplib.rst
@@ -37,6 +37,19 @@ base class:
initialized. If *host* is not specified, ``''`` (the local host) is used. If
*port* is omitted, the standard IMAP4 port (143) is used.
+ The :class:`IMAP4` class supports the :keyword:`with` statement. When used
+ like this, the IMAP4 ``LOGOUT`` command is issued automatically when the
+ :keyword:`with` statement exits. E.g.::
+
+ >>> from imaplib import IMAP4
+ >>> with IMAP4("domain.org") as M:
+ ... M.noop()
+ ...
+ ('OK', [b'Nothing Accomplished. d25if65hy903weo.87'])
+
+ .. versionchanged:: 3.5
+ Support for the :keyword:`with` statement was added.
+
Three exceptions are defined as attributes of the :class:`IMAP4` class:
@@ -64,7 +77,8 @@ Three exceptions are defined as attributes of the :class:`IMAP4` class:
There's also a subclass for secure connections:
-.. class:: IMAP4_SSL(host='', port=IMAP4_SSL_PORT, keyfile=None, certfile=None, ssl_context=None)
+.. class:: IMAP4_SSL(host='', port=IMAP4_SSL_PORT, keyfile=None, \
+ certfile=None, ssl_context=None)
This is a subclass derived from :class:`IMAP4` that connects over an SSL
encrypted socket (to use this class you need a socket module that was compiled
@@ -198,6 +212,10 @@ 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.
+ .. versionchanged:: 3.5
+ string usernames and passwords are now encoded to ``utf-8`` instead of
+ being limited to ASCII.
+
.. method:: IMAP4.check()
@@ -230,6 +248,16 @@ An :class:`IMAP4` instance has the following methods:
Delete the ACLs (remove any rights) set for who on mailbox.
+.. method:: IMAP4.enable(capability)
+
+ Enable *capability* (see :rfc:`5161`). Most capabilities do not need to be
+ enabled. Currently only the ``UTF8=ACCEPT`` capability is supported
+ (see :RFC:`6855`).
+
+ .. versionadded:: 3.5
+ The :meth:`enable` method itself, and :RFC:`6855` support.
+
+
.. method:: IMAP4.expunge()
Permanently remove deleted items from selected mailbox. Generates an ``EXPUNGE``
@@ -367,7 +395,9 @@ An :class:`IMAP4` instance has the following methods:
Search mailbox for matching messages. *charset* may be ``None``, in which case
no ``CHARSET`` will be specified in the request to the server. The IMAP
protocol requires that at least one criterion be specified; an exception will be
- raised when the server returns an error.
+ raised when the server returns an error. *charset* must be ``None`` if
+ the ``UTF8=ACCEPT`` capability was enabled using the :meth:`enable`
+ command.
Example::
@@ -529,6 +559,15 @@ The following attributes are defined on instances of :class:`IMAP4`:
the module variable ``Debug``. Values greater than three trace each command.
+.. attribute:: IMAP4.utf8_enabled
+
+ Boolean value that is normally ``False``, but is set to ``True`` if an
+ :meth:`enable` command is successfully issued for the ``UTF8=ACCEPT``
+ capability.
+
+ .. versionadded:: 3.5
+
+
.. _imap4-example:
IMAP4 Example