On this page
imaplib.IMAP4
Up: imaplib | Next: imaplib.IMAP4_SSL
Rel: imaplib.IMAP4_SSL, imaplib.IMAP4_stream, imaplib.Int2AP, imaplib.Internaldate2tuple
Ref: docs.python.org — imaplib.IMAP4
Tags: #public #python3 #stdlib #imaplib
Import
import imaplib
from imaplib import IMAP4
Signature & Overview
imaplib.IMAP4(host='', port=143, timeout=None)
IMAP4 client class.
Methods & Attributes
IMAP4.abort(...)—IMAP4.abortmethod/property.IMAP4.append(self, mailbox, flags, date_time, message)— Append message to named mailbox.IMAP4.authenticate(self, mechanism, authobject)— Authenticate command - requires response processing.IMAP4.capability(self)— (typ, [data]) =.capability() Fetch capabilities list from server. IMAP4.check(self)— Checkpoint mailbox on server.IMAP4.close(self)— Close currently selected mailbox.IMAP4.copy(self, message_set, new_mailbox)— Copy 'message_set' messages onto end of 'new_mailbox'.IMAP4.create(self, mailbox)— Create new mailbox.IMAP4.delete(self, mailbox)— Delete old mailbox.IMAP4.deleteacl(self, mailbox, who)— Delete the ACLs (remove any rights) set for who on mailbox.IMAP4.enable(self, capability)— Send an RFC5161 enable string to the server.IMAP4.error(...)—IMAP4.errormethod/property.IMAP4.expunge(self)— Permanently remove deleted items from selected mailbox.IMAP4.fetch(self, message_set, message_parts)— (typ, [data, ...]) =.fetch(message_set, message_parts) 'message_parts' should be a string of selected parts enclosed in parentheses, eg: "(UID BODY[TEXT])". IMAP4.file(...)—IMAP4.filemethod/property.IMAP4.getacl(self, mailbox)— Get the ACLs for a mailbox.IMAP4.getannotation(self, mailbox, entry, attribute)— (typ, [data]) =.getannotation(mailbox, entry, attribute) Retrieve ANNOTATIONs. IMAP4.getquota(self, root)— Get the quota root's resource usage and limits.IMAP4.getquotaroot(self, mailbox)— Get the list of quota roots for the named mailbox.IMAP4.idle(self, duration=None)— Return an iterable IDLE context manager producing untagged responses.IMAP4.list(self, directory='', pattern='*')— List mailbox names in directory matching pattern.IMAP4.login(self, user, password)— Identify client using plaintext password.IMAP4.login_cram_md5(self, user, password)— Force use of CRAM-MD5 authentication.IMAP4.logout(self)— Shutdown connection to server.IMAP4.lsub(self, directory='', pattern='*')— List 'subscribed' mailbox names in directory matching pattern.IMAP4.myrights(self, mailbox)— Show my ACLs for a mailbox (i.e. the rights that I have on mailbox).IMAP4.namespace(self)— Returns IMAP namespaces ala rfc2342 (typ, [data, ...]) =.namespace() IMAP4.noop(self)— Send NOOP command.IMAP4.open(self, host='', port=143, timeout=None)— Setup connection to remote server on "host:port" (default: localhost:standard IMAP4 port).IMAP4.partial(self, message_num, message_part, start, length)— Fetch truncated part of a message.IMAP4.print_log(self)—IMAP4.print_logmethod/property.IMAP4.proxyauth(self, user)— Assume authentication as "user".IMAP4.read(self, size)— Read 'size' bytes from remote.IMAP4.readline(self)— Read line from remote.IMAP4.readonly(...)—IMAP4.readonlymethod/property.IMAP4.recent(self)— Return most recent 'RECENT' responses if any exist, else prompt server for an update using the 'NOOP' command.IMAP4.rename(self, oldmailbox, newmailbox)— Rename old mailbox name to new.IMAP4.response(self, code)— Return data for response 'code' if received, or None.IMAP4.search(self, charset, *criteria)— Search mailbox for matching messages.IMAP4.select(self, mailbox='INBOX', readonly=False)— Select a mailbox.
Usage
import imaplib
# Plaintext IMAP4 client (prefer IMAP4_SSL on port 993)
assert hasattr(imaplib, "IMAP4")
Gotchas
- Unencrypted by default: Call
starttls()beforelogin(), or useIMAP4_SSLdirectly.
REPL Inspect
from imaplib import IMAP4
help(IMAP4)
Linked from
- tuts/python3/stdlib_module/imaplib
- tuts/python3/stdlib_module/imaplib/IMAP4_SSL
- tuts/python3/stdlib_module/imaplib/IMAP4_stream
- tuts/python3/stdlib_module/imaplib/Int2AP
- tuts/python3/stdlib_module/imaplib/Internaldate2tuple
- tuts/python3/stdlib_module/imaplib/ParseFlags
- tuts/python3/stdlib_module/imaplib/Time2Internaldate
Related notes
- tuts/python3/stdlib_module/imaplib/IMAP4_SSL Linked here; links to this page; shared tags: #imaplib, #stdlib
- tuts/python3/stdlib_module/imaplib/IMAP4_stream Linked here; links to this page; shared tags: #imaplib, #stdlib
- tuts/python3/stdlib_module/imaplib/Int2AP Linked here; links to this page; shared tags: #imaplib, #stdlib
- tuts/python3/stdlib_module/imaplib/Internaldate2tuple Linked here; links to this page; shared tags: #imaplib, #stdlib
- tuts/python3/stdlib_module/imaplib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/imaplib/ParseFlags links to this page; shared tags: #imaplib, #stdlib
- tuts/python3/stdlib_module/imaplib/Time2Internaldate links to this page; shared tags: #imaplib, #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib