💾 Archived View for tris.fyi › pydoc › imaplib captured on 2023-04-26 at 13:30:05. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-01-08)
-=-=-=-=-=-=-
IMAP4 client. Based on RFC 2060. Public class: IMAP4 Public variable: Debug Public functions: Internaldate2tuple Int2AP ParseFlags Time2Internaldate
IMAP4 client class. Instantiate with: IMAP4([host[, port[, timeout=None]]]) host - host's name (default: localhost); port - port number (default: standard IMAP4 port). timeout - socket timeout (default: None) If timeout is not given or is None, the global default socket timeout is used 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 <instance>.error("<reason>"). IMAP4 server errors raise <instance>.abort("<reason>"), which is a sub-class of 'error'. Mailbox status changes from READ-WRITE to READ-ONLY raise the exception class <instance>.readonly("<reason>"), 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. Also, most IMAP servers implement a sub-set of the commands available here.
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
append(self, mailbox, flags, date_time, message) Append message to named mailbox. (typ, [data]) = <instance>.append(mailbox, flags, date_time, message) All args except `message' can be None.
authenticate(self, mechanism, authobject) Authenticate command - requires response processing. 'mechanism' specifies which authentication mechanism is to be used - it must appear in <instance>.capabilities in the form AUTH=<mechanism>. 'authobject' must be a callable object: data = authobject(response) It will be called to process server continuation responses; the response argument it is passed will be a bytes. It should return bytes data that will be base64 encoded and sent to the server. It should return None if the client abort response '*' should be sent instead.
capability(self) (typ, [data]) = <instance>.capability() Fetch capabilities list from server.
check(self) Checkpoint mailbox on server. (typ, [data]) = <instance>.check()
close(self) Close currently selected mailbox. Deleted messages are removed from writable mailbox. This is the recommended command before 'LOGOUT'. (typ, [data]) = <instance>.close()
copy(self, message_set, new_mailbox) Copy 'message_set' messages onto end of 'new_mailbox'. (typ, [data]) = <instance>.copy(message_set, new_mailbox)
create(self, mailbox) Create new mailbox. (typ, [data]) = <instance>.create(mailbox)
delete(self, mailbox) Delete old mailbox. (typ, [data]) = <instance>.delete(mailbox)
deleteacl(self, mailbox, who) Delete the ACLs (remove any rights) set for who on mailbox. (typ, [data]) = <instance>.deleteacl(mailbox, who)
enable(self, capability) Send an RFC5161 enable string to the server. (typ, [data]) = <instance>.enable(capability)
expunge(self) Permanently remove deleted items from selected mailbox. Generates 'EXPUNGE' response for each deleted message. (typ, [data]) = <instance>.expunge() 'data' is list of 'EXPUNGE'd message numbers in order received.
fetch(self, message_set, message_parts) Fetch (parts of) messages. (typ, [data, ...]) = <instance>.fetch(message_set, message_parts) 'message_parts' should be a string of selected parts enclosed in parentheses, eg: "(UID BODY[TEXT])". 'data' are tuples of message part envelope and data.
getacl(self, mailbox) Get the ACLs for a mailbox. (typ, [data]) = <instance>.getacl(mailbox)
getannotation(self, mailbox, entry, attribute) (typ, [data]) = <instance>.getannotation(mailbox, entry, attribute) Retrieve ANNOTATIONs.
getquota(self, root) Get the quota root's resource usage and limits. Part of the IMAP4 QUOTA extension defined in rfc2087. (typ, [data]) = <instance>.getquota(root)
getquotaroot(self, mailbox) Get the list of quota roots for the named mailbox. (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox)
list(self, directory='""', pattern='*') List mailbox names in directory matching pattern. (typ, [data]) = <instance>.list(directory='""', pattern='*') 'data' is list of LIST responses.
login(self, user, password) Identify client using plaintext password. (typ, [data]) = <instance>.login(user, password) NB: 'password' will be quoted.
login_cram_md5(self, user, password) Force use of CRAM-MD5 authentication. (typ, [data]) = <instance>.login_cram_md5(user, password)
logout(self) Shutdown connection to server. (typ, [data]) = <instance>.logout() Returns server 'BYE' response.
lsub(self, directory='""', pattern='*') List 'subscribed' mailbox names in directory matching pattern. (typ, [data, ...]) = <instance>.lsub(directory='""', pattern='*') 'data' are tuples of message part envelope and data.
myrights(self, mailbox) Show my ACLs for a mailbox (i.e. the rights that I have on mailbox). (typ, [data]) = <instance>.myrights(mailbox)
namespace(self) Returns IMAP namespaces ala rfc2342 (typ, [data, ...]) = <instance>.namespace()
noop(self) Send NOOP command. (typ, [data]) = <instance>.noop()
open(self, host='', port=143, timeout=None) Setup connection to remote server on "host:port" (default: localhost:standard IMAP4 port). This connection will be used by the routines: read, readline, send, shutdown.
partial(self, message_num, message_part, start, length) Fetch truncated part of a message. (typ, [data, ...]) = <instance>.partial(message_num, message_part, start, length) 'data' is tuple of message part envelope and data.
print_log(self)
proxyauth(self, user) Assume authentication as "user". Allows an authorised administrator to proxy into any user's mailbox. (typ, [data]) = <instance>.proxyauth(user)
read(self, size) Read 'size' bytes from remote.
readline(self) Read line from remote.
recent(self) Return most recent 'RECENT' responses if any exist, else prompt server for an update using the 'NOOP' command. (typ, [data]) = <instance>.recent() 'data' is None if no new messages, else list of RECENT responses, most recent last.
rename(self, oldmailbox, newmailbox) Rename old mailbox name to new. (typ, [data]) = <instance>.rename(oldmailbox, newmailbox)
response(self, code) Return data for response 'code' if received, or None. Old value for response 'code' is cleared. (code, [data]) = <instance>.response(code)
search(self, charset, *criteria) Search mailbox for matching messages. (typ, [data]) = <instance>.search(charset, criterion, ...) 'data' is space separated list of matching message numbers. If UTF8 is enabled, charset MUST be None.
select(self, mailbox='INBOX', readonly=False) Select a mailbox. Flush all untagged responses. (typ, [data]) = <instance>.select(mailbox='INBOX', readonly=False) 'data' is count of messages in mailbox ('EXISTS' response). Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so other responses should be obtained via <instance>.response('FLAGS') etc.
send(self, data) Send data to remote.
setacl(self, mailbox, who, what) Set a mailbox acl. (typ, [data]) = <instance>.setacl(mailbox, who, what)
setannotation(self, *args) (typ, [data]) = <instance>.setannotation(mailbox[, entry, attribute]+) Set ANNOTATIONs.
setquota(self, root, limits) Set the quota root's resource limits. (typ, [data]) = <instance>.setquota(root, limits)
shutdown(self) Close I/O established in "open".
socket(self) Return socket instance used to connect to IMAP4 server. socket = <instance>.socket()
sort(self, sort_criteria, charset, *search_criteria) IMAP4rev1 extension SORT command. (typ, [data]) = <instance>.sort(sort_criteria, charset, search_criteria, ...)
starttls(self, ssl_context=None)
status(self, mailbox, names) Request named status conditions for mailbox. (typ, [data]) = <instance>.status(mailbox, names)
store(self, message_set, command, flags) Alters flag dispositions for messages in mailbox. (typ, [data]) = <instance>.store(message_set, command, flags)
subscribe(self, mailbox) Subscribe to new mailbox. (typ, [data]) = <instance>.subscribe(mailbox)
thread(self, threading_algorithm, charset, *search_criteria) IMAPrev1 extension THREAD command. (type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)
uid(self, command, *args) Execute "command arg ..." with messages identified by UID, rather than message number. (typ, [data]) = <instance>.uid(command, arg1, arg2, ...) Returns response appropriate to 'command'.
unselect(self) Free server's resources associated with the selected mailbox and returns the server to the authenticated state. This command performs the same actions as CLOSE, except that no messages are permanently removed from the currently selected mailbox. (typ, [data]) = <instance>.unselect()
unsubscribe(self, mailbox) Unsubscribe from old mailbox. (typ, [data]) = <instance>.unsubscribe(mailbox)
xatom(self, name, *args) Allow simple extension commands notified by server in CAPABILITY response. Assumes command is legal in current state. (typ, [data]) = <instance>.xatom(name, arg, ...) Returns response appropriate to extension command `name'.
IMAP4 client class over SSL connection Instantiate with: IMAP4_SSL([host[, port[, keyfile[, certfile[, ssl_context[, timeout=None]]]]]]) host - host's name (default: localhost); port - port number (default: standard IMAP4 SSL port); keyfile - PEM formatted file that contains your private key (default: None); certfile - PEM formatted certificate chain file (default: None); ssl_context - a SSLContext object that contains your certificate chain and private key (default: None) Note: if ssl_context is provided, then parameters keyfile or certfile should not be set otherwise ValueError is raised. timeout - socket timeout (default: None) If timeout is not given or is None, the global default socket timeout is used for more documentation see the docstring of the parent class IMAP4.
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
append(self, mailbox, flags, date_time, message) Append message to named mailbox. (typ, [data]) = <instance>.append(mailbox, flags, date_time, message) All args except `message' can be None.
authenticate(self, mechanism, authobject) Authenticate command - requires response processing. 'mechanism' specifies which authentication mechanism is to be used - it must appear in <instance>.capabilities in the form AUTH=<mechanism>. 'authobject' must be a callable object: data = authobject(response) It will be called to process server continuation responses; the response argument it is passed will be a bytes. It should return bytes data that will be base64 encoded and sent to the server. It should return None if the client abort response '*' should be sent instead.
capability(self) (typ, [data]) = <instance>.capability() Fetch capabilities list from server.
check(self) Checkpoint mailbox on server. (typ, [data]) = <instance>.check()
close(self) Close currently selected mailbox. Deleted messages are removed from writable mailbox. This is the recommended command before 'LOGOUT'. (typ, [data]) = <instance>.close()
copy(self, message_set, new_mailbox) Copy 'message_set' messages onto end of 'new_mailbox'. (typ, [data]) = <instance>.copy(message_set, new_mailbox)
create(self, mailbox) Create new mailbox. (typ, [data]) = <instance>.create(mailbox)
delete(self, mailbox) Delete old mailbox. (typ, [data]) = <instance>.delete(mailbox)
deleteacl(self, mailbox, who) Delete the ACLs (remove any rights) set for who on mailbox. (typ, [data]) = <instance>.deleteacl(mailbox, who)
enable(self, capability) Send an RFC5161 enable string to the server. (typ, [data]) = <instance>.enable(capability)
expunge(self) Permanently remove deleted items from selected mailbox. Generates 'EXPUNGE' response for each deleted message. (typ, [data]) = <instance>.expunge() 'data' is list of 'EXPUNGE'd message numbers in order received.
fetch(self, message_set, message_parts) Fetch (parts of) messages. (typ, [data, ...]) = <instance>.fetch(message_set, message_parts) 'message_parts' should be a string of selected parts enclosed in parentheses, eg: "(UID BODY[TEXT])". 'data' are tuples of message part envelope and data.
getacl(self, mailbox) Get the ACLs for a mailbox. (typ, [data]) = <instance>.getacl(mailbox)
getannotation(self, mailbox, entry, attribute) (typ, [data]) = <instance>.getannotation(mailbox, entry, attribute) Retrieve ANNOTATIONs.
getquota(self, root) Get the quota root's resource usage and limits. Part of the IMAP4 QUOTA extension defined in rfc2087. (typ, [data]) = <instance>.getquota(root)
getquotaroot(self, mailbox) Get the list of quota roots for the named mailbox. (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox)
list(self, directory='""', pattern='*') List mailbox names in directory matching pattern. (typ, [data]) = <instance>.list(directory='""', pattern='*') 'data' is list of LIST responses.
login(self, user, password) Identify client using plaintext password. (typ, [data]) = <instance>.login(user, password) NB: 'password' will be quoted.
login_cram_md5(self, user, password) Force use of CRAM-MD5 authentication. (typ, [data]) = <instance>.login_cram_md5(user, password)
logout(self) Shutdown connection to server. (typ, [data]) = <instance>.logout() Returns server 'BYE' response.
lsub(self, directory='""', pattern='*') List 'subscribed' mailbox names in directory matching pattern. (typ, [data, ...]) = <instance>.lsub(directory='""', pattern='*') 'data' are tuples of message part envelope and data.
myrights(self, mailbox) Show my ACLs for a mailbox (i.e. the rights that I have on mailbox). (typ, [data]) = <instance>.myrights(mailbox)
namespace(self) Returns IMAP namespaces ala rfc2342 (typ, [data, ...]) = <instance>.namespace()
noop(self) Send NOOP command. (typ, [data]) = <instance>.noop()
open(self, host='', port=993, timeout=None) Setup connection to remote server on "host:port". (default: localhost:standard IMAP4 SSL port). This connection will be used by the routines: read, readline, send, shutdown.
partial(self, message_num, message_part, start, length) Fetch truncated part of a message. (typ, [data, ...]) = <instance>.partial(message_num, message_part, start, length) 'data' is tuple of message part envelope and data.
print_log(self)
proxyauth(self, user) Assume authentication as "user". Allows an authorised administrator to proxy into any user's mailbox. (typ, [data]) = <instance>.proxyauth(user)
read(self, size) Read 'size' bytes from remote.
readline(self) Read line from remote.
recent(self) Return most recent 'RECENT' responses if any exist, else prompt server for an update using the 'NOOP' command. (typ, [data]) = <instance>.recent() 'data' is None if no new messages, else list of RECENT responses, most recent last.
rename(self, oldmailbox, newmailbox) Rename old mailbox name to new. (typ, [data]) = <instance>.rename(oldmailbox, newmailbox)
response(self, code) Return data for response 'code' if received, or None. Old value for response 'code' is cleared. (code, [data]) = <instance>.response(code)
search(self, charset, *criteria) Search mailbox for matching messages. (typ, [data]) = <instance>.search(charset, criterion, ...) 'data' is space separated list of matching message numbers. If UTF8 is enabled, charset MUST be None.
select(self, mailbox='INBOX', readonly=False) Select a mailbox. Flush all untagged responses. (typ, [data]) = <instance>.select(mailbox='INBOX', readonly=False) 'data' is count of messages in mailbox ('EXISTS' response). Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so other responses should be obtained via <instance>.response('FLAGS') etc.
send(self, data) Send data to remote.
setacl(self, mailbox, who, what) Set a mailbox acl. (typ, [data]) = <instance>.setacl(mailbox, who, what)
setannotation(self, *args) (typ, [data]) = <instance>.setannotation(mailbox[, entry, attribute]+) Set ANNOTATIONs.
setquota(self, root, limits) Set the quota root's resource limits. (typ, [data]) = <instance>.setquota(root, limits)
shutdown(self) Close I/O established in "open".
socket(self) Return socket instance used to connect to IMAP4 server. socket = <instance>.socket()
sort(self, sort_criteria, charset, *search_criteria) IMAP4rev1 extension SORT command. (typ, [data]) = <instance>.sort(sort_criteria, charset, search_criteria, ...)
starttls(self, ssl_context=None)
status(self, mailbox, names) Request named status conditions for mailbox. (typ, [data]) = <instance>.status(mailbox, names)
store(self, message_set, command, flags) Alters flag dispositions for messages in mailbox. (typ, [data]) = <instance>.store(message_set, command, flags)
subscribe(self, mailbox) Subscribe to new mailbox. (typ, [data]) = <instance>.subscribe(mailbox)
thread(self, threading_algorithm, charset, *search_criteria) IMAPrev1 extension THREAD command. (type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)
uid(self, command, *args) Execute "command arg ..." with messages identified by UID, rather than message number. (typ, [data]) = <instance>.uid(command, arg1, arg2, ...) Returns response appropriate to 'command'.
unselect(self) Free server's resources associated with the selected mailbox and returns the server to the authenticated state. This command performs the same actions as CLOSE, except that no messages are permanently removed from the currently selected mailbox. (typ, [data]) = <instance>.unselect()
unsubscribe(self, mailbox) Unsubscribe from old mailbox. (typ, [data]) = <instance>.unsubscribe(mailbox)
xatom(self, name, *args) Allow simple extension commands notified by server in CAPABILITY response. Assumes command is legal in current state. (typ, [data]) = <instance>.xatom(name, arg, ...) Returns response appropriate to extension command `name'.
IMAP4 client class over a stream Instantiate with: IMAP4_stream(command) "command" - a string that can be passed to subprocess.Popen() for more documentation see the docstring of the parent class IMAP4.
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
append(self, mailbox, flags, date_time, message) Append message to named mailbox. (typ, [data]) = <instance>.append(mailbox, flags, date_time, message) All args except `message' can be None.
authenticate(self, mechanism, authobject) Authenticate command - requires response processing. 'mechanism' specifies which authentication mechanism is to be used - it must appear in <instance>.capabilities in the form AUTH=<mechanism>. 'authobject' must be a callable object: data = authobject(response) It will be called to process server continuation responses; the response argument it is passed will be a bytes. It should return bytes data that will be base64 encoded and sent to the server. It should return None if the client abort response '*' should be sent instead.
capability(self) (typ, [data]) = <instance>.capability() Fetch capabilities list from server.
check(self) Checkpoint mailbox on server. (typ, [data]) = <instance>.check()
close(self) Close currently selected mailbox. Deleted messages are removed from writable mailbox. This is the recommended command before 'LOGOUT'. (typ, [data]) = <instance>.close()
copy(self, message_set, new_mailbox) Copy 'message_set' messages onto end of 'new_mailbox'. (typ, [data]) = <instance>.copy(message_set, new_mailbox)
create(self, mailbox) Create new mailbox. (typ, [data]) = <instance>.create(mailbox)
delete(self, mailbox) Delete old mailbox. (typ, [data]) = <instance>.delete(mailbox)
deleteacl(self, mailbox, who) Delete the ACLs (remove any rights) set for who on mailbox. (typ, [data]) = <instance>.deleteacl(mailbox, who)
enable(self, capability) Send an RFC5161 enable string to the server. (typ, [data]) = <instance>.enable(capability)
expunge(self) Permanently remove deleted items from selected mailbox. Generates 'EXPUNGE' response for each deleted message. (typ, [data]) = <instance>.expunge() 'data' is list of 'EXPUNGE'd message numbers in order received.
fetch(self, message_set, message_parts) Fetch (parts of) messages. (typ, [data, ...]) = <instance>.fetch(message_set, message_parts) 'message_parts' should be a string of selected parts enclosed in parentheses, eg: "(UID BODY[TEXT])". 'data' are tuples of message part envelope and data.
getacl(self, mailbox) Get the ACLs for a mailbox. (typ, [data]) = <instance>.getacl(mailbox)
getannotation(self, mailbox, entry, attribute) (typ, [data]) = <instance>.getannotation(mailbox, entry, attribute) Retrieve ANNOTATIONs.
getquota(self, root) Get the quota root's resource usage and limits. Part of the IMAP4 QUOTA extension defined in rfc2087. (typ, [data]) = <instance>.getquota(root)
getquotaroot(self, mailbox) Get the list of quota roots for the named mailbox. (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox)
list(self, directory='""', pattern='*') List mailbox names in directory matching pattern. (typ, [data]) = <instance>.list(directory='""', pattern='*') 'data' is list of LIST responses.
login(self, user, password) Identify client using plaintext password. (typ, [data]) = <instance>.login(user, password) NB: 'password' will be quoted.
login_cram_md5(self, user, password) Force use of CRAM-MD5 authentication. (typ, [data]) = <instance>.login_cram_md5(user, password)
logout(self) Shutdown connection to server. (typ, [data]) = <instance>.logout() Returns server 'BYE' response.
lsub(self, directory='""', pattern='*') List 'subscribed' mailbox names in directory matching pattern. (typ, [data, ...]) = <instance>.lsub(directory='""', pattern='*') 'data' are tuples of message part envelope and data.
myrights(self, mailbox) Show my ACLs for a mailbox (i.e. the rights that I have on mailbox). (typ, [data]) = <instance>.myrights(mailbox)
namespace(self) Returns IMAP namespaces ala rfc2342 (typ, [data, ...]) = <instance>.namespace()
noop(self) Send NOOP command. (typ, [data]) = <instance>.noop()
open(self, host=None, port=None, timeout=None) Setup a stream connection. This connection will be used by the routines: read, readline, send, shutdown.
partial(self, message_num, message_part, start, length) Fetch truncated part of a message. (typ, [data, ...]) = <instance>.partial(message_num, message_part, start, length) 'data' is tuple of message part envelope and data.
print_log(self)
proxyauth(self, user) Assume authentication as "user". Allows an authorised administrator to proxy into any user's mailbox. (typ, [data]) = <instance>.proxyauth(user)
read(self, size) Read 'size' bytes from remote.
readline(self) Read line from remote.
recent(self) Return most recent 'RECENT' responses if any exist, else prompt server for an update using the 'NOOP' command. (typ, [data]) = <instance>.recent() 'data' is None if no new messages, else list of RECENT responses, most recent last.
rename(self, oldmailbox, newmailbox) Rename old mailbox name to new. (typ, [data]) = <instance>.rename(oldmailbox, newmailbox)
response(self, code) Return data for response 'code' if received, or None. Old value for response 'code' is cleared. (code, [data]) = <instance>.response(code)
search(self, charset, *criteria) Search mailbox for matching messages. (typ, [data]) = <instance>.search(charset, criterion, ...) 'data' is space separated list of matching message numbers. If UTF8 is enabled, charset MUST be None.
select(self, mailbox='INBOX', readonly=False) Select a mailbox. Flush all untagged responses. (typ, [data]) = <instance>.select(mailbox='INBOX', readonly=False) 'data' is count of messages in mailbox ('EXISTS' response). Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so other responses should be obtained via <instance>.response('FLAGS') etc.
send(self, data) Send data to remote.
setacl(self, mailbox, who, what) Set a mailbox acl. (typ, [data]) = <instance>.setacl(mailbox, who, what)
setannotation(self, *args) (typ, [data]) = <instance>.setannotation(mailbox[, entry, attribute]+) Set ANNOTATIONs.
setquota(self, root, limits) Set the quota root's resource limits. (typ, [data]) = <instance>.setquota(root, limits)
shutdown(self) Close I/O established in "open".
socket(self) Return socket instance used to connect to IMAP4 server. socket = <instance>.socket()
sort(self, sort_criteria, charset, *search_criteria) IMAP4rev1 extension SORT command. (typ, [data]) = <instance>.sort(sort_criteria, charset, search_criteria, ...)
starttls(self, ssl_context=None)
status(self, mailbox, names) Request named status conditions for mailbox. (typ, [data]) = <instance>.status(mailbox, names)
store(self, message_set, command, flags) Alters flag dispositions for messages in mailbox. (typ, [data]) = <instance>.store(message_set, command, flags)
subscribe(self, mailbox) Subscribe to new mailbox. (typ, [data]) = <instance>.subscribe(mailbox)
thread(self, threading_algorithm, charset, *search_criteria) IMAPrev1 extension THREAD command. (type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)
uid(self, command, *args) Execute "command arg ..." with messages identified by UID, rather than message number. (typ, [data]) = <instance>.uid(command, arg1, arg2, ...) Returns response appropriate to 'command'.
unselect(self) Free server's resources associated with the selected mailbox and returns the server to the authenticated state. This command performs the same actions as CLOSE, except that no messages are permanently removed from the currently selected mailbox. (typ, [data]) = <instance>.unselect()
unsubscribe(self, mailbox) Unsubscribe from old mailbox. (typ, [data]) = <instance>.unsubscribe(mailbox)
xatom(self, name, *args) Allow simple extension commands notified by server in CAPABILITY response. Assumes command is legal in current state. (typ, [data]) = <instance>.xatom(name, arg, ...) Returns response appropriate to extension command `name'.
datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]]) The year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.
astimezone(...) tz -> convert to local time in new timezone tz
combine(...) date, time -> datetime with same date and time fields
ctime(...) Return ctime() style string.
date(...) Return date object with same year, month and day.
dst(...) Return self.tzinfo.dst(self).
fromisocalendar(...) int, int, int -> Construct a date from the ISO year, week number and weekday. This is the inverse of the date.isocalendar() function
fromisoformat(...) string -> datetime from datetime.isoformat() output
fromordinal(...) int -> date corresponding to a proleptic Gregorian ordinal.
fromtimestamp(...) timestamp[, tz] -> tz's local time from POSIX timestamp.
isocalendar(...) Return a named tuple containing ISO year, week number, and weekday.
isoformat(...) [sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM]. sep is used to separate the year from the time, and defaults to 'T'. The optional argument timespec specifies the number of additional terms of the time to include. Valid options are 'auto', 'hours', 'minutes', 'seconds', 'milliseconds' and 'microseconds'.
isoweekday(...) Return the day of the week represented by the date. Monday == 1 ... Sunday == 7
now(tz=None) Returns new datetime object representing current time local to tz. tz Timezone object. If no tz is specified, uses local timezone.
replace(...) Return datetime with new specified fields.
strftime(...) format -> strftime() style string.
strptime(...) string, format -> new datetime parsed from a string (like time.strptime()).
time(...) Return time object with same time but with tzinfo=None.
timestamp(...) Return POSIX timestamp as float.
timetuple(...) Return time tuple, compatible with time.localtime().
timetz(...) Return time object with same time and tzinfo.
today(...) Current date or datetime: same as self.__class__.fromtimestamp(time.time()).
toordinal(...) Return proleptic Gregorian ordinal. January 1 of year 1 is day 1.
tzname(...) Return self.tzinfo.tzname(self).
utcfromtimestamp(...) Construct a naive UTC datetime from a POSIX timestamp.
utcnow(...) Return a new datetime representing UTC day and time.
utcoffset(...) Return self.tzinfo.utcoffset(self).
utctimetuple(...) Return UTC time tuple, compatible with time.localtime().
weekday(...) Return the day of the week represented by the date. Monday == 0 ... Sunday == 6
day = <attribute 'day' of 'datetime.date' objects>
fold = <attribute 'fold' of 'datetime.datetime' objects>
hour = <attribute 'hour' of 'datetime.datetime' objects>
max = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)
microsecond = <attribute 'microsecond' of 'datetime.datetime' objects>
min = datetime.datetime(1, 1, 1, 0, 0)
minute = <attribute 'minute' of 'datetime.datetime' objects>
month = <attribute 'month' of 'datetime.date' objects>
resolution = datetime.timedelta(microseconds=1)
second = <attribute 'second' of 'datetime.datetime' objects>
tzinfo = <attribute 'tzinfo' of 'datetime.datetime' objects>
year = <attribute 'year' of 'datetime.date' objects>
Difference between two datetime values. timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0) All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative.
total_seconds(...) Total seconds in the duration.
days = <member 'days' of 'datetime.timedelta' objects> Number of days.
max = datetime.timedelta(days=999999999, seconds=86399, microseconds=999999)
microseconds = <member 'microseconds' of 'datetime.timedelta' objects> Number of microseconds (>= 0 and less than 1 second).
min = datetime.timedelta(days=-999999999)
resolution = datetime.timedelta(microseconds=1)
seconds = <member 'seconds' of 'datetime.timedelta' objects> Number of seconds (>= 0 and less than 1 day).
Fixed offset from UTC implementation of tzinfo.
dst(...) Return None.
fromutc(...) datetime in UTC -> datetime in local time.
tzname(...) If name is specified when timezone is created, returns the name. Otherwise returns offset as 'UTC(+|-)HH:MM'.
utcoffset(...) Return fixed offset.
max = datetime.timezone(datetime.timedelta(seconds=86340))
min = datetime.timezone(datetime.timedelta(days=-1, seconds=60))
utc = datetime.timezone.utc
Int2AP(num) Convert integer to A-P string representation.
Internaldate2tuple(resp) Parse an IMAP4 INTERNALDATE string. Return corresponding local time. The return value is a time.struct_time tuple or None if the string has wrong format.
ParseFlags(resp) Convert IMAP4 flags response to python tuple.
Time2Internaldate(date_time) Convert date_time to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'. The date_time argument can be a number (int or float) representing seconds since epoch (as returned by time.time()), a 9-tuple representing local time, an instance of time.struct_time (as returned by time.localtime()), an aware datetime instance or a double-quoted string. In the last case, it is assumed to already be in the correct format.
AllowedVersions = ('IMAP4REV1', 'IMAP4')
CRLF = b'\r\n'
Commands = {'APPEND': ('AUTH', 'SELECTED'), 'AUTHENTICATE': ('NONAUTH',), 'CAPABILITY': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'), 'CHECK': ('SELECTED',), 'CLOSE': ('SELECTED',), 'COPY': ('SELECTED',), 'CREATE': ('AUTH', 'SELECTED'), 'DELETE': ('AUTH', 'SELECTED'), 'DELETEACL': ('AUTH', 'SELECTED'), 'ENABLE': ('AUTH',), 'EXAMINE': ('AUTH', 'SELECTED'), 'EXPUNGE': ('SELECTED',), 'FETCH': ('SELECTED',), 'GETACL': ('AUTH', 'SELECTED'), 'GETANNOTATION': ('AUTH', 'SELECTED'), 'GETQUOTA': ('AUTH', 'SELECTED'), 'GETQUOTAROOT': ('AUTH', 'SELECTED'), 'MYRIGHTS': ('AUTH', 'SELECTED'), 'LIST': ('AUTH', 'SELECTED'), 'LOGIN': ('NONAUTH',), 'LOGOUT': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'), 'LSUB': ('AUTH', 'SELECTED'), 'MOVE': ('SELECTED',), 'NAMESPACE': ('AUTH', 'SELECTED'), 'NOOP': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'), 'PARTIAL': ('SELECTED',), 'PROXYAUTH': ('AUTH',), 'RENAME': ('AUTH', 'SELECTED'), 'SEARCH': ('SELECTED',), 'SELECT': ('AUTH', 'SELECTED'), 'SETACL': ('AUTH', 'SELECTED'), 'SETANNOTATION': ('AUTH', 'SELECTED'), 'SETQUOTA': ('AUTH', 'SELECTED'), 'SORT': ('SELECTED',), 'STARTTLS': ('NONAUTH',), 'STATUS': ('AUTH', 'SELECTED'), 'STORE': ('SELECTED',), 'SUBSCRIBE': ('AUTH', 'SELECTED'), 'THREAD': ('SELECTED',), 'UID': ('SELECTED',), 'UNSUBSCRIBE': ('AUTH', 'SELECTED'), 'UNSELECT': ('SELECTED',)}
Continuation = re.compile(b'\\+( (?P<data>.*))?')
DEFAULT_BUFFER_SIZE = 8192
Debug = 0
Flags = re.compile(b'.*FLAGS \\((?P<flags>[^\\)]*)\\)')
HAVE_SSL = True
IMAP4_PORT = 143
IMAP4_SSL_PORT = 993
InternalDate = re.compile(b'.*INTERNALDATE "(?P<day>[ 0123][0-9])-(?P<mon>[A-Z][a-z][a-z])-(?P<year>[0-9][0-9][0-9][0-9]) (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9]) (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zon)
Literal = re.compile(b'.*{(?P<size>\\d+)}