This module defines three classes, IMAP4, IMAP4_SSL and IMAP4_stream, which encapsulate a connection to an IMAP4 server and implement a large subset of the IMAP4rev1 client protocol as defined in RFC 2060. It is backward compatible with IMAP4 (RFC 1730) servers, but note that the "STATUS" command is not supported in IMAP4.
Three classes are provided by the imaplib module, IMAP4 is the base class:
''(the local host) is used. If port is omitted, the standard IMAP4 port (143) is used.
Three exceptions are defined as attributes of the IMAP4 class:
There's also a subclass for secure connections:
|[host[, port[, keyfile[, certfile]]]])|
''(the local host) is used. If port is omitted, the standard IMAP4-over-SSL port (993) is used. keyfile and certfile are also optional - they can contain a PEM formatted private key and certificate chain file for the SSL connection.
The second subclass allows for connections created by a child process:
stdin/stdoutfile descriptors created by passing command to
os.popen2(). New in version 2.3.
The following utility functions are defined:
"DD-Mmm-YYYY HH:MM:SS +HHMM"(including double-quotes).
Note that IMAP4 message numbers change as the mailbox changes; in particular, after an "EXPUNGE" command performs deletions the remaining messages are renumbered. So it is highly advisable to use UIDs instead, with the UID command.
At the end of the module, there is a test section that contains a more extensive example of usage.
Documents describing the protocol, and sources and binaries for servers implementing it, can all be found at the University of Washington's IMAP Information Center (http://www.cac.washington.edu/imap/).