Class
imaplib.IMAP4

IMAP4 client class.

Instantiate with: IMAP4([host[, port]])

host - host's name (default: localhost); port - port number (default: standard IMAP4 port).

All IMAP4rev1 commands are supported by methods of the same name (in lower-case).

All arguments to commands are converted to strings, except for AUTHENTICATE, and the last argument to APPEND which is passed as an IMAP4 literal. If necessary (the string contains any non-printing characters or white-space and isn't enclosed with either parentheses or double quotes) each string is quoted. However, the password argument to the LOGIN command is always quoted. If you want to avoid having an argument string quoted (eg: the flags argument to STORE) then enclose the string in parentheses (eg: "(\Deleted)").

Each command returns a tuple: (type, [data, ...]) where type is usually OK or NO, and data is either the text from the tagged response, or untagged results from command. Each data is either a string, or a tuple. If a tuple, then the first part is the header of the response, and the second part contains the data (ie: literal value).

Errors raise the exception class .error(""). IMAP4 server errors raise .abort(""), which is a sub-class of error. Mailbox status changes from READ-WRITE to READ-ONLY raise the exception class .readonly(""), which is a sub-class of abort.

"error" exceptions imply a program error. "abort" exceptions imply the connection should be reset, and the command re-tried. "readonly" exceptions imply the command should be re-tried.

Note: to use this module, you must read the RFCs pertaining to the IMAP4 protocol, as the semantics of the arguments to each IMAP4 command are left to the invoker, not to mention the results.

Base classes

There are no base classes.

Implemented Interfaces

There are no implemented interfaces.

Attributes/Properties

Methods

Known Subclasses