Expand description
IMAP (Internet Message Access Protocol) layer implementation.
Implements RFC 3501 IMAP4rev1 packet parsing as a zero-copy view into a packet buffer.
§Protocol Overview
IMAP operates over TCP port 143 (993 for IMAPS). Unlike POP3, IMAP keeps messages on the server and supports folders, multiple clients, and partial message fetching.
§Message Format
Client Command:
tag COMMAND [arguments]\r\nWhere tag is an alphanumeric identifier assigned by the client (e.g., “A001”).
Server Untagged Response (data/status):
* STATUS [data]\r\n
* NUMBER TYPE [data]\r\nServer Tagged Response (command completion):
tag OK [text]\r\n
tag NO [text]\r\n
tag BAD [text]\r\nServer Continuation Request:
+ [text]\r\n§Server Response Status Codes
| Code | Meaning |
|---|---|
| OK | Command completed successfully |
| NO | Command failed |
| BAD | Protocol error |
| BYE | Server closing connection |
| PREAUTH | Already authenticated |
§Common IMAP Commands (RFC 3501)
| Command | State | Description |
|---|---|---|
| CAPABILITY | Any | List server capabilities |
| NOOP | Any | No-op |
| LOGOUT | Any | End session |
| AUTHENTICATE | NonAuth | SASL authentication |
| LOGIN | NonAuth | Plaintext login |
| STARTTLS | NonAuth | TLS upgrade (RFC 2595) |
| SELECT | Auth | Select mailbox (read-write) |
| EXAMINE | Auth | Select mailbox (read-only) |
| CREATE | Auth | Create mailbox |
| DELETE | Auth | Delete mailbox |
| RENAME | Auth | Rename mailbox |
| SUBSCRIBE | Auth | Add to subscription list |
| UNSUBSCRIBE | Auth | Remove from subscription list |
| LIST | Auth | List mailboxes |
| LSUB | Auth | List subscribed mailboxes |
| STATUS | Auth | Request mailbox status |
| APPEND | Auth | Append message to mailbox |
| CHECK | Select | Checkpoint mailbox |
| CLOSE | Select | Close selected mailbox |
| EXPUNGE | Select | Remove deleted messages |
| SEARCH | Select | Search messages |
| FETCH | Select | Retrieve message data |
| STORE | Select | Alter message flags |
| COPY | Select | Copy messages to another mailbox |
| UID | Select | UID variant of COPY/FETCH/SEARCH/STORE |
Re-exports§
pub use builder::ImapBuilder;
Modules§
- builder
- IMAP packet builder.
Structs§
- Imap
Layer - A zero-copy view into an IMAP layer within a packet buffer.
Constants§
- CMD_
APPEND - CMD_
AUTHENTICATE - CMD_
CAPABILITY - CMD_
CHECK - CMD_
CLOSE - CMD_
COPY - CMD_
CREATE - CMD_
DELETE - CMD_
EXAMINE - CMD_
EXPUNGE - CMD_
FETCH - CMD_
LIST - CMD_
LOGIN - CMD_
LOGOUT - CMD_
LSUB - CMD_
NOOP - CMD_
RENAME - CMD_
SEARCH - CMD_
SELECT - CMD_
STARTTLS - CMD_
STATUS - CMD_
STORE - CMD_
SUBSCRIBE - CMD_UID
- CMD_
UNSUBSCRIBE - IMAPS_
PORT - IMAPS (over TLS) port.
- IMAP_
MIN_ HEADER_ LEN - Minimum IMAP payload size.
- IMAP_
PORT - IMAP standard port.
- STATUS_
BAD - STATUS_
BYE - STATUS_
NO - STATUS_
OK - IMAP tagged response status strings.
- STATUS_
PREAUTH
Statics§
- IMAP_
COMMANDS - IMAP_
FIELD_ NAMES - Field names for Python/generic access.
Functions§
- imap_
show_ fields - Returns a human-readable display of IMAP layer fields.
- is_
imap_ payload - Returns true if
buflooks like an IMAP payload.