Debian Codegraph @

doc/src/index.rst

raw
1 ============
2 IMAPClient
3 ============
4
5 :Author: `Menno Finlay-Smits <http://menno.io/>`_
6 :Version: |release|
7 :Date: |today|
8 :Homepage: http://imapclient.freshfoo.com
9 :Download: http://pypi.python.org/pypi/IMAPClient/
10 :Source code: https://github.com/mjs/imapclient
11 :Documentation: http://imapclient.readthedocs.io/
12 :License: `New BSD License <http://en.wikipedia.org/wiki/BSD_licenses>`_
13 :Forum/Support: https://github.com/mjs/imapclient/discussions
14
15 Introduction
16 ------------
17 IMAPClient is an easy-to-use, Pythonic and complete IMAP client
18 library.
19
20 Although IMAPClient actually uses the imaplib module from the Python
21 standard library under the hood, it provides a different API. Instead
22 of requiring that the caller performs extra parsing work, return
23 values are full parsed, readily usable and use sensible Python
24 types. Exceptions are raised when problems occur (no error checking of
25 return values is required).
26
27 IMAPClient is straightforward to use, but it can be useful to have at
28 least a general understanding of the IMAP protocol. :rfc:`3501`
29 explains IMAP in detail. Other RFCs also apply to various extensions
30 to the base protocol. These are referred to in the documentation below
31 where relevant.
32
33 Python versions 3.8 through 3.14 are officially supported.
34
35 Getting Started
36 ---------------
37
38 Install IMAPClient::
39
40 $ pip install imapclient
41
42 See :ref:`Installation <installation>` for more details.
43
44 The core of the IMAPClient API is the IMAPClient class. Instantiating
45 this class, creates a connection to an IMAP account. Calling methods
46 on the IMAPClient instance interacts with the server.
47
48 The following example shows a simple interaction with an IMAP server.
49 It displays the message ID, subject and date of the message for all
50 messages in the INBOX folder.
51
52 ::
53
54 >>> from imapclient import IMAPClient
55 >>> server = IMAPClient('imap.mailserver.com', use_uid=True)
56 >>> server.login('someuser', 'somepassword')
57 b'[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR [...] LIST-STATUS QUOTA] Logged in'
58
59 >>> select_info = server.select_folder('INBOX')
60 >>> print('%d messages in INBOX' % select_info[b'EXISTS'])
61 34 messages in INBOX
62
63 >>> messages = server.search(['FROM', '[email protected]'])
64 >>> print("%d messages from our best friend" % len(messages))
65 5 messages from our best friend
66
67 >>> for msgid, data in server.fetch(messages, ['ENVELOPE']).items():
68 >>> envelope = data[b'ENVELOPE']
69 >>> print('ID #%d: "%s" received %s' % (msgid, envelope.subject.decode(), envelope.date))
70 ID #62: "Our holidays photos" received 2017-07-20 21:47:42
71 ID #55: "Re: did you book the hotel?" received 2017-06-26 10:38:09
72 ID #53: "Re: did you book the hotel?" received 2017-06-25 22:02:58
73 ID #44: "See that fun article about lobsters in Pacific ocean!" received 2017-06-09 09:49:47
74 ID #46: "Planning for our next vacations" received 2017-05-12 10:29:30
75
76 >>> server.logout()
77 b'Logging out'
78
79 User Guide
80 ----------
81 This section describes how IMAPClient works and gives some examples to
82 help you start.
83
84 .. toctree::
85 :maxdepth: 2
86
87 installation
88 concepts
89 advanced
90
91
92 API Reference
93 -------------
94 This section describes public functions and classes of IMAPClient
95 library.
96
97 .. toctree::
98 :maxdepth: 2
99
100 api
101
102
103 Contributor Guide
104 -----------------
105 .. toctree::
106 :maxdepth: 2
107
108 contributing
109
110
111 External Documentation
112 ----------------------
113 The `Unofficial IMAP Protocol Wiki <http://www.imapwiki.org/>`_ is
114 very useful when writing IMAP related software and is highly
115 recommended.
116
117
118 Authors
119 -------
120
121 .. include:: ../../AUTHORS.rst
122
123
124 Release History
125 ---------------
126
127 From release 3.0.0 onwards, release notes are maintained `on Github
128 <https://github.com/mjs/imapclient/releases>`_.
129
130 Release notes for older versions can be found :doc:`in these docs <releases>`.