Skip to main content

Crate rusmes_imap

Crate rusmes_imap 

Source
Expand description

IMAP protocol implementation for RusMES

This crate provides a full-featured, RFC-compliant IMAP server implementation built on Tokio for asynchronous I/O.

§RFC Compliance

  • RFC 9051 (IMAP4rev2) / RFC 3501 (IMAP4rev1): Core IMAP protocol
  • RFC 7162 (CONDSTORE / QRESYNC): Efficient mailbox synchronization with MODSEQ tracking, CHANGEDSINCE/UNCHANGEDSINCE modifiers, and VANISHED responses
  • RFC 6154 (SPECIAL-USE): \Drafts, \Sent, \Trash, \Junk, etc.
  • RFC 4315 (UIDPLUS): APPENDUID and COPYUID response codes
  • RFC 6851 (MOVE): MOVE command and COPYUID response for moves
  • RFC 2177 (IDLE): Server-push idle notification
  • RFC 2342 (NAMESPACE): Personal, shared, and other-users namespaces
  • RFC 2449 (CAPABILITY): Capability advertisement

§Supported Commands

§Not Authenticated State

  • CAPABILITY — List server capabilities
  • NOOP — No-operation (keep-alive)
  • LOGOUT — Disconnect
  • LOGIN user password — Plain-text authentication
  • AUTHENTICATE mechanism — SASL authentication (PLAIN, LOGIN, CRAM-MD5, SCRAM-SHA-256, XOAUTH2)

§Authenticated State

  • SELECT mailbox — Open mailbox read-write
  • EXAMINE mailbox — Open mailbox read-only
  • CREATE mailbox — Create new mailbox (with optional SPECIAL-USE flag)
  • DELETE mailbox — Delete a mailbox
  • RENAME old new — Rename a mailbox
  • SUBSCRIBE mailbox — Subscribe to a mailbox
  • UNSUBSCRIBE mailbox — Unsubscribe from a mailbox
  • LIST reference mailbox — List mailboxes matching a pattern
  • LSUB reference mailbox — List subscribed mailboxes matching a pattern
  • NAMESPACE — Query server namespaces
  • APPEND mailbox ... — Append a message to a mailbox

§Selected State

  • FETCH sequence items — Retrieve message data
  • STORE sequence flags — Modify message flags
  • SEARCH criteria — Search for messages
  • COPY sequence mailbox — Copy messages to another mailbox
  • MOVE sequence mailbox — Move messages to another mailbox
  • EXPUNGE — Permanently delete messages with \Deleted flag
  • CLOSE — Implicit expunge and deselect
  • IDLE — Enter server-push idle mode (RFC 2177)
  • UID FETCH/STORE/SEARCH/COPY/MOVE/EXPUNGE — UID-based variants

§Modules

  • authenticate: SASL multi-step authentication (PLAIN, LOGIN, CRAM-MD5, SCRAM-SHA-256, XOAUTH2)
  • command: IMAP command enumeration and types
  • condstore: CONDSTORE extension — MODSEQ, CHANGEDSINCE, UNCHANGEDSINCE
  • config: Server configuration (ImapConfig)
  • handler: Command dispatcher (HandlerContext, handle_command)
  • handler_auth: LOGIN and LOGOUT handlers
  • handler_mailbox: Mailbox-level command handlers
  • handler_message: Message-level command handlers (FETCH, STORE, etc.)
  • mailbox_watcher: Watches for mailbox changes to support IDLE push notifications
  • parser: IMAP command-line parser including APPEND literal handling
  • qresync: QRESYNC extension — UID range sets, vanished responses
  • response: IMAP response formatting (tagged OK/NO/BAD, untagged *)
  • server: Async TCP listener accepting IMAP connections
  • session: Per-connection state machine (NotAuthenticated → Authenticated → Selected ↔ Idle → Logout)
  • special_use: SPECIAL-USE mailbox attributes (RFC 6154)

§Security

All random challenge material (CRAM-MD5, SCRAM nonces) is generated via getrandom for cryptographic-quality entropy. In production deployments, TLS should be enabled to protect LOGIN/PLAIN credentials in transit.

Re-exports§

pub use authenticate::create_default_sasl_server;
pub use authenticate::handle_authenticate;
pub use authenticate::handle_authenticate_continue;
pub use authenticate::parse_authenticate_args;
pub use authenticate::AuthenticateContext;
pub use authenticate::AuthenticateState;
pub use command::ImapCommand;
pub use command::StoreMode;
pub use condstore::ChangedSince;
pub use condstore::CondStoreError;
pub use condstore::CondStoreResponse;
pub use condstore::CondStoreState;
pub use condstore::CondStoreStatus;
pub use condstore::UnchangedSince;
pub use config::ImapConfig;
pub use handler::handle_command;
pub use handler::HandlerContext;
pub use mailbox_watcher::MailboxChanges;
pub use mailbox_watcher::MailboxWatcher;
pub use parser::has_literal;
pub use parser::parse_append_command;
pub use parser::parse_command;
pub use parser::LiteralType;
pub use qresync::QResyncError;
pub use qresync::QResyncLogic;
pub use qresync::QResyncParams;
pub use qresync::QResyncState;
pub use qresync::SeqMatchData;
pub use qresync::UidRange;
pub use qresync::UidSet;
pub use qresync::VanishedResponse;
pub use response::ImapResponse;
pub use server::ImapServer;
pub use session::ImapSession;
pub use session::ImapState;
pub use session::MailboxSnapshot;
pub use special_use::format_capability_response;
pub use special_use::format_list_extended;
pub use special_use::parse_create_special_use;
pub use special_use::suggest_special_use;
pub use special_use::validate_special_use_flags;
pub use special_use::SpecialUse;
pub use special_use::SpecialUseError;
pub use special_use::SpecialUseFlags;
pub use special_use::LIST_EXTENDED_CAPABILITY;
pub use special_use::SPECIAL_USE_CAPABILITY;

Modules§

authenticate
IMAP AUTHENTICATE command implementation with SASL integration
command
IMAP command types
condstore
IMAP CONDSTORE Extension - RFC 7162
config
IMAP server configuration
handler
IMAP command handler dispatcher
handler_auth
IMAP authentication command handlers (LOGIN, LOGOUT)
handler_mailbox
IMAP mailbox command handlers
handler_message
IMAP message command handlers
mailbox_watcher
Mailbox change detection for IDLE support
parser
IMAP command parser
qresync
IMAP QRESYNC Extension - RFC 7162
response
IMAP response types
server
IMAP server implementation
session
IMAP session state machine
special_use
IMAP SPECIAL-USE extension (RFC 6154)