Accessing IMAP accounts

IMAP is a protocol for accessing mail. Like POP, it enables you to read and delete messages. IMAP offers additional features, such as searching for message text and organizing messages in separate mailboxes. However, IMAP is harder to use than POP, and is far less commonly used.

See RFC 2060 for the full description of IMAP4rev1.

The module imaplib provides a class, IMAP4, to serve as an IMAP client. The names of IMAP4 methods correspond to the commands of the IMAP protocol. Most methods return a tuple (code, data), where code is "OK" (good) or "NO" (bad), and data is the text of the server response.

The IMAP protocol includes various magical behaviors. For example, you can move all the messages from INBOX into a new mailbox by attempting to rename INBOX. (The INBOX folder isn't actually renamed, but its contents are moved to the other mailbox!) Not all the features of the protocol are covered here; consult RFC 2060 for more information.

0 0

Post a comment