NGEMITY_
← All Labs
LABS / MAIL

Mail

A self-hosted Rust mail backend with a portable Svelte frontend. Host the mail engine and its data where you choose; the interface uses its API and can reach different devices and platforms. Multiple IMAP accounts, SMTP sending and CalDAV calendars share a workspace with offline support.

Why I built it

Your inbox contains conversations, documents, appointments and a detailed record of your life. Choosing where the mailbox lives is one part of owning that data. The software you use to read it can also maintain its own copies, credentials, search state and connection to your providers. I want to control that part too.

NGemity Mail separates a self-hosted Rust mail backend from a Svelte frontend. I can host the backend where I choose, with its database, synchronization workers, account connections and notification delivery in a deployment I operate. I know where that system holds my data, who administers it and how it is backed up. Multiple mail and calendar providers remain accessible through standard IMAP, SMTP and CalDAV connections.

The reason for that separation is portability. The frontend uses the backend’s API, so the mail engine does not have to move with the interface. The same Svelte application can serve as the basis for web, desktop and mobile frontends, all connecting to the Rust server I host. Changing the device or how the frontend is packaged does not require rebuilding the mail synchronization and provider integrations for each platform.

That is the reason to build it: ownership of the interface and the system handling my mail on my behalf, with an everyday experience that works across devices. Mail providers still hold the messages on their servers, and browser caches and push delivery have their own data paths. Self-hosting the client makes its part of that relationship mine to operate.

Mail is an everyday interface to a surprisingly difficult distributed system. I built a client that puts multiple mail accounts and calendars in one workspace, while making delayed synchronization, offline work and failed or uncertain delivery understandable.

Inside Mail

Captured from an isolated demo using fictional mail, contacts and calendar events. Desktop and phone views show the same Svelte web frontend at different screen sizes.

Mail desktop workspace with multiple accounts, a unified inbox and a conversation reading pane
A unified inbox keeps personal, studio and community accounts together, with conversation history beside the message list.
Mail desktop calendar with a week timeline and events from several calendars
The calendar workspace brings separate calendars into one week view, with a color for each calendar and direct access to event details.
Mail phone layout showing a message and mobile reply controls
On a phone, the reader gets its own screen and reply actions stay within reach above the workspace navigation.
Mail phone calendar in agenda view with upcoming fictional events
Agenda view gives upcoming events room on a narrow screen. Mail and Calendar remain available through the bottom navigation.

How it fits together

A Rust/Axum mail backend exposes an API to a separate Svelte 5 and TypeScript frontend. The backend owns IMAP, SMTP, discovery, storage, push and CalDAV through dedicated crates. PostgreSQL holds user-scoped caches, encrypted connection credentials and durable operation state. The frontend consumes the API; provider protocols and credentials stay on the server. This boundary lets the interface travel across platforms while the backend stays where I choose to host it.

  1. Portable mail & calendar frontend

    Svelte 5 · API adapter · IndexedDB · web / PWA

  2. Self-hosted Rust mail backend

    Axum API · OIDC · PostgreSQL · sync · push

  3. Independent providers

    IMAP reading · SMTP sending · CalDAV calendars

Main application boundaries in Mail.

Read, reply and recover from interruption

A single message crosses several systems. The client distinguishes a local edit, a saved draft, an accepted submission and a filed Sent copy.

  1. Connect and start reading

    After OIDC sign-in, connect one or more IMAP accounts. The newest 100 headers per selectable mailbox arrive first; older headers load in background batches. Bodies and attachments load on demand.

  2. Keep working offline

    Recent summaries and opened messages can be read from the bounded local cache. Supported flag and move changes queue for review; composer recovery retains local work. Reconnection verifies the session before replay.

  3. Send the confirmed draft

    Outgoing SMTP is configured separately. Sending requires a connection and the confirmed draft version. A durable submission receipt records the operation before transmission starts.

  4. Handle an uncertain result

    If transmission may have succeeded but the acknowledgement is lost, that version is not submitted again. If delivery succeeds but Sent filing fails, the client reports a filing warning and retries filing without resending the email.

Engineering choices

A few details behind the everyday behavior. Expand a choice for the implementation.

Email HTML is a separate documentSender formatting never becomes application markup.

Formatted mail uses sanitized, sandboxed documents with scripts disabled and external images blocked by default. Plain-text viewing and explicit image loading remain available. Inline attachments can render locally; authenticated attachment routes return downloads. Sender CSS cannot restyle the surrounding workspace.

Calendar edits preserve the provider’s revisionIndependent CalDAV accounts use conditional writes and visible conflicts.

Day, week, month and agenda views share timezone-aware events and recurrence handling. ETags prevent silent overwrites, while durable operation IDs help reconcile lost acknowledgements. Offline calendar edits retain their revisions for replay. Unsupported calendar formats are reported explicitly; invitations and responses depend on provider-side automatic scheduling.

One backend, a portable frontendHost the mail engine once; deliver the interface across devices.

The frontend accesses mail and calendar operations through typed adapters. Its API adapter connects to the Rust server, keeping synchronization and provider integrations independent of the frontend’s packaging. Web and installable PWA delivery are implemented. Desktop and mobile packaging can build on the same Svelte frontend and API boundary; the dedicated Tauri transport adapter remains an unimplemented extension point. The local demo uses a separate adapter with persisted example data, and API builds exclude those fixtures entirely.

Current status & limits

Implemented & evolving

Active development, with a standalone local demo and a connected Rust backend. Implemented workflows include multiple accounts, folders, conversations, search, rich-text drafts, SMTP sending, CalDAV events, offline changes and Web Push. Protocol fixtures and browser suites exercise these paths in the source project.

Practical boundaries

The backend connects to existing IMAP, SMTP and CalDAV providers through separately configured connections; provider-specific OAuth is not implemented. The connected web deployment currently serves frontend and API on the same origin. Native desktop and mobile packaging remain extension work. Sending always needs a connection. Only cached mail and calendar ranges are available offline. SMTP cannot guarantee exactly-once delivery after a lost acknowledgement, and background notifications depend on browser and OS support.

Explore the implementation

Source and documentation for the workflows described here.