Skip to main content

Module imap

Module imap 

Source
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\n

Where 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\n

Server Tagged Response (command completion):

tag OK [text]\r\n
tag NO [text]\r\n
tag BAD [text]\r\n

Server Continuation Request:

+ [text]\r\n

§Server Response Status Codes

CodeMeaning
OKCommand completed successfully
NOCommand failed
BADProtocol error
BYEServer closing connection
PREAUTHAlready authenticated

§Common IMAP Commands (RFC 3501)

CommandStateDescription
CAPABILITYAnyList server capabilities
NOOPAnyNo-op
LOGOUTAnyEnd session
AUTHENTICATENonAuthSASL authentication
LOGINNonAuthPlaintext login
STARTTLSNonAuthTLS upgrade (RFC 2595)
SELECTAuthSelect mailbox (read-write)
EXAMINEAuthSelect mailbox (read-only)
CREATEAuthCreate mailbox
DELETEAuthDelete mailbox
RENAMEAuthRename mailbox
SUBSCRIBEAuthAdd to subscription list
UNSUBSCRIBEAuthRemove from subscription list
LISTAuthList mailboxes
LSUBAuthList subscribed mailboxes
STATUSAuthRequest mailbox status
APPENDAuthAppend message to mailbox
CHECKSelectCheckpoint mailbox
CLOSESelectClose selected mailbox
EXPUNGESelectRemove deleted messages
SEARCHSelectSearch messages
FETCHSelectRetrieve message data
STORESelectAlter message flags
COPYSelectCopy messages to another mailbox
UIDSelectUID variant of COPY/FETCH/SEARCH/STORE

Re-exports§

pub use builder::ImapBuilder;

Modules§

builder
IMAP packet builder.

Structs§

ImapLayer
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 buf looks like an IMAP payload.