1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//! IMAP protocol implementation for RusMES
//!
// The `BufReader<RawInflateReader<...>>` type used in imap_session_loop after
// COMPRESS=DEFLATE negotiation is deeply nested enough that the default recursion
// limit (128) is exhausted when the trait solver proves `Send` for the
// tokio::spawn future in server.rs. Bump to 512 to give the solver enough headroom.
//!
//! 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.
pub use ;
pub use ;
pub use ;
pub use ImapConfig;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ImapResponse;
pub use ImapServer;
pub use ;
pub use ;