All IMAP4rev1 commands are represented by methods of the same name,
either upper-case or 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 IMAP4
protocol-sensitive characters 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: r'(\Deleted)').
Each command returns a tuple: (type, [data,
...]) where type is usually 'OK' or 'NO',
and data is either the text from the command response, or
mandated results from the command.
Permanently remove deleted items from selected mailbox. Generates an
"EXPUNGE" response for each deleted message. Returned data
contains a list of "EXPUNGE" message numbers in order
received.
Fetch (parts of) messages. message_parts should be
a string of message part names enclosed within parentheses,
eg: ""(UID BODY[TEXT])"". Returned data are tuples
of message part envelope and data.
List mailbox names in directory matching
pattern. directory defaults to the top-level mail
folder, and pattern defaults to match anything. Returned data
contains a list of "LIST" responses.
List subscribed mailbox names in directory matching pattern.
directory defaults to the top level directory and
pattern defaults to match any mailbox.
Returned data are tuples of message part envelope and data.
Search mailbox for matching messages. Returned data contains a space
separated list of matching message numbers. 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
criterium be specified; an exception will be raised when the server
returns an error.
Example:
# M is a connected IMAP4 instance...
msgnums = M.search(None, 'FROM', '"LDJ"')
# or:
msgnums = M.search(None, '(FROM "LDJ")')
Select a mailbox. Returned data is the count of messages in
mailbox ("EXISTS" response). The default mailbox
is 'INBOX'. If the readonly flag is set, modifications
to the mailbox are not allowed.
Execute command args with messages identified by UID, rather than
message number. Returns response appropriate to command. At least
one argument must be supplied; if none are provided, the server will
return an error and an exception will be raised.