Implement IMAP IDLE with admin observability#124
Merged
Conversation
Agent-Logs-Url: https://github.com/tayyebi/mailserver/sessions/61e37ed3-3507-4cc9-8269-e4823140f274 Co-authored-by: tayyebi <14053493+tayyebi@users.noreply.github.com>
…, pre-format timestamp before lock Agent-Logs-Url: https://github.com/tayyebi/mailserver/sessions/61e37ed3-3507-4cc9-8269-e4823140f274 Co-authored-by: tayyebi <14053493+tayyebi@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
tayyebi
April 21, 2026 13:24
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements IMAP IDLE (RFC 2177) for the webmail client using Server-Sent Events (SSE), and exposes active IDLE sessions in the admin area.
What is IMAP IDLE here?
The webmail reads mail directly from Maildir on disk without going through the IMAP protocol. IMAP IDLE is the mechanism where the server pushes new-mail notifications to the client instead of the client polling. The web equivalent is Server-Sent Events — a persistent HTTP connection over which the server streams events as they happen.
Changes
Backend
tokio-streamadded as a dependency for bridgingtokio::sync::mpscreceivers into asyncStreams required by axum'sSsetypeImapIdleSessionstruct andImapIdleRegistry(Arc<Mutex<HashMap<String, ImapIdleSession>>>) added toAppState(insrc/web/mod.rs)GET /webmail/idle?account_id=X&folder=YSSE endpoint (src/web/routes/webmail.rs):Maildir/new/every 5 s (withMissedTickBehavior::Delay)mailboxSSE event{"new_count": N}when the count changesGET /imap-idleadmin page (src/web/routes/imap_idle.rs): lists all currently active IDLE sessions with username, domain, folder, connected_at, last_ping_atFrontend
templates/webmail/inbox.html) gains a JavaScript SSE client that:EventSourceto/webmail/idlewhen an account is selectedaccount_idandfolderfrom HTMLdata-*attributes (not direct JS template interpolation — avoids any XSS risk)templates/layout.html) gains an IMAP IDLE link under the Clients grouptemplates/dashboard.html+src/web/routes/dashboard.rs) shows a live IMAP IDLE counter cardDovecot config
templates/config/dovecot.conf.txtgainsimap_idle_notify_interval = 2 mins, explicitly configuring Dovecot's native IMAP IDLE notification interval for external IMAP clients