0%
Cybersecurity

SupaMail: Inside the Secure Email Platform We Built

An email platform engineered as a security product in its own right: a full SMTP engine, S/MIME over a complete PKI, DKIM, and an append-only audit trail — with every security claim verified automatically in CI, not just documented.

SupaMail app icon by XARKLO

The problem: email is a wide attack surface, and documented security is not enough

Email is the gateway most breaches walk through: spoofing, senders acting in your name with missing or forged signatures, messages travelling unencrypted, malicious attachments, and conversation logs that can be altered with no trace. The deeper problem is that many products carry a secure label in marketing while the actual claims were never verified.

That is why we built SupaMail the opposite way: start with an architecture that enforces the security, then let CI verify every one of the claims automatically on each build.

What SupaMail is

SupaMail is four build tracks on one base: a self-owned mail server, a PWA web app, a standalone edition that runs on Supabase's free tiers, and a companion mobile app — with a design-system token set that keeps one visual identity across every platform.

argon2id + TOTP MFAauth & strict sessions
S/MIME + PKIfull certificate chain
RLS + E2EEisolation + optional E2EE
CI-verifiedsecurity enforced in CI

The mail server (server/)

Node.js / NestJS with a full SMTP engine: argon2id + TOTP MFA, sessions with an access token + refresh cookie (HttpOnly/SameSite=Strict), S/MIME signing/encryption backed by a complete PKI (CA, certificates, CRL, OCSP), DKIM + STARTTLS with per-message SPF/DKIM/DMARC classification, an append-only sha256-chained audit log with verifyChain(), and malware scanning with quarantine of suspicious attachments.

The web app (web/)

A Next.js 15 PWA talking to the server through mail / compose / certificates / admin / security pages — a nonce-CSP, and the access token kept in memory only, never in persistent storage.

The standalone edition (supamail/)

Next.js + Supabase on the free tiers: full data isolation via Postgres RLS — reading another user's data is impossible — with optional browser E2EE (ECDH P-256 + AES-256-GCM with non-extractable keys), auto-lock with WebAuthn, offline drafts and sending via IndexedDB, Push (VAPID), Realtime, threads, rich-text sanitized with DOMPurify, and signed URL attachments.

The mobile app (mobile/)

A companion Flutter app with a visual identity drawn from the same design tokens, and icons ready for web, PWA, Android, and iOS.

Security is enforced, not claimed

The real reference for the project is README.md and docs/security/posture.md: every documented security claim has a matching test or check that runs in CI on each build. Here are the pillars that are actually verified:

Auth and sessions

Passwords stored as argon2id, TOTP-based two-factor authentication, and sessions built on short-lived access tokens plus a refresh cookie with HttpOnly and SameSite=Strict.

Encryption and signatures

S/MIME encryption and signing over a complete PKI that issues its own certificates: CA, certificates, CRL, and OCSP — so every message can be signed and verified against a real certificate chain.

Transport and identity

DKIM signing on every message, STARTTLS transport, and per-message SPF/DKIM/DMARC classification so a message's authenticity is known before it is shown.

Audit

An append-only audit log where every entry is chained to the previous one via SHA-256, with a verifyChain() function that checks the integrity of the entire chain — any alteration breaks the chain visibly.

Attachments

Malware scanning on every attachment, with suspicious files quarantined in an isolated area instead of being delivered to the user.

The client

A nonce-CSP on the frontend, and the access token held in memory only — so no sensitive token sits in permanent storage waiting to be stolen.

Why a standalone Supabase edition?

Some teams want secure email without running a self-owned server — so the standalone edition runs on Supabase's free tiers and makes isolation the identity: Postgres Row-Level Security at the row level, so no user can read another user's data even when trying through a direct API. On top of that, optional E2EE encrypts messages in the browser before they ever touch the server.

The app is an installable PWA, works offline with drafts stored in IndexedDB, imports .eml and .mbox files, and is documented with end-to-end tests through Playwright.

Full RLS isolation

Postgres RLS denies cross-boundary access by default — the architecture is the moat, not goodwill.

Optional browser E2EE

ECDH P-256 + AES-256-GCM with non-extractable keys that never leave your device.

Auto-lock and WebAuthn

The device locks when idle, and unlocks with a fingerprint or a WebAuthn security key.

Capable daily tools

Push (VAPID), Realtime updates, threads, rich text sanitized with DOMPurify, and attachments delivered through signed URLs.

Tech stack and the live app

NestJS / Node.js / TypeScript on the server, Next.js 15 + TypeScript on the web, PostgreSQL and Supabase for data, and Flutter for mobile — with the real references (README.md and docs/security/posture.md) whose claims are verified automatically in CI. The live app is on Vercel:

https://supamail-nu.vercel.app/