AbstractAbstractconnectOpens a connection to an IMAP server and authenticates.
Server address, port, TLS setting, and credentials
An opaque session handle for subsequent operations
AbstractlistLists all mailboxes (folders) on the server.
Session handle from connect()
Array of mailbox descriptors
AbstractselectSelects a mailbox for subsequent search/fetch/flag operations.
Session handle from connect()
Mailbox name (e.g. "INBOX")
Mailbox status including message count and UID validity
AbstractsearchSearches for messages matching the given criteria in the selected mailbox.
All criteria fields are ANDed together. Returns UIDs (not sequence numbers).
Session handle from connect()
Search criteria (all optional, ANDed)
Array of matching message UIDs
AbstractfetchFetches message data for the given UIDs.
By default fetches headers only. Set body: true in options to include
message body content. The implementation handles MIME decoding internally.
Session handle from connect()
Array of message UIDs to fetch
Optionaloptions: ImapFetchOptionsWhat to fetch (headers, body, body type)
Array of message objects with requested fields populated
AbstractsetModifies flags on messages.
Common flags: "\Seen" (read), "\Flagged" (starred), "\Deleted" (marked for deletion).
Session handle from connect()
Array of message UIDs to modify
Flags to add/remove/set (e.g. ["\Seen"])
"add", "remove", or "set" (replace all flags)
AbstractdisconnectCloses the IMAP connection.
Always call this when done, preferably in a finally block.
Session handle from connect()
Built-in tool for IMAP email access.
Provides high-level IMAP operations for reading email and managing flags. Handles TCP/TLS connections, IMAP protocol details, and MIME decoding internally.
Permission model: Connectors declare which IMAP hosts they need access to. Connections to undeclared hosts are rejected.
Example