๐จ Mail
Read and reply to your work email without switching tabs. Gmail today; Outlook + Yahoo + custom IMAP next. Connect once via OAuth, get a unified inbox with full folder support, spam filtering, and HIPAA-grade audit on every read.
Live at synalux.ai/mailย .
โ๏ธ Unified Inbox Across Providers
One inbox view that combines mail from every connected provider. Click a thread to read inline; reply without leaving the page.
- Connect once โ OAuth handshake via the generic Connect-Integration pattern; no per-provider page changes.
- Folder support โ inbox, spam, all, plus user-specific labels (Gmail) / folders (Outlook).
- Thread view โ full RFC 2822 threading; collapses replies; expands quoted history on demand.
- Search โ server-side search across subject, from, body (workspace-scoped, RLS-enforced).

๐ค Send + Reply In-Place
- Compose โ rich-text + plain-text modes; auto-saves drafts every 3 seconds.
- Reply / Reply-All โ threads on the original Message-ID, preserves provider-side conversation grouping.
- Attachments โ uploaded via the Drive module; storage_path validated against allowlist (no path traversal).
- Body sanitization โ
body_htmlis HTML-escaped on render to close stored XSS via crafted incoming mail.
๐ก๏ธ Spam Blocker Module
Built-in spam classification with per-workspace block lists.
- Per-workspace block list โ admins block sender/domain; immediate effect across the workspace.
- Provider-side spam folder is still respected (Gmailโs classifier wins on its own labels).
- Phishing heuristics โ flags links pointing to recently-registered domains, mismatched SPF/DKIM, lookalike-domain tactics.
๐ Connect-Integration Pattern
Adding a new mail provider (e.g. Outlook) is ~30 LOC because all providers go through a generic OAuth + message-provider abstraction.
- Connect cards are auto-rendered from a provider declaration โ no per-provider UI page.
- Token storage: OAuth tokens AES-256-GCM encrypted at rest; per-workspace isolation enforced.
- Token refresh is centralized; expiry detected and rotated transparently.
- CLI for ops:
portal/scripts/fetch-messages.mjsto pull mail outside the web flow (e.g. for bulk import).
๐ HIPAA + Audit
- Every read writes an
oauth_token_access_logrow with operation type (list / read / send / delete) so an auditor can reconstruct who accessed what and when. - Workspace isolation guard โ
requireWorkspaceMemberruns on every endpoint; RLS double-locks at the database layer. - Credential encryption โ provider tokens never stored in plaintext.
- No PHI in URLs โ all sensitive identifiers in POST body / signed cookies; logs scrub query strings.
๐๏ธ Architecture
GET /api/v1/mail/inbox List threads (folder=inbox|spam|all)
GET /api/v1/mail/thread/:id Full thread with quoted history
POST /api/v1/mail/send Send / reply (validates attachments)
POST /api/v1/mail/sync Force-sync from provider (bulk pull)
GET /api/v1/mail/ai-inbox AI-categorized inbox (smart priority)
GET /api/v1/mail/suggest-replies AI-generated reply suggestions
GET /api/v1/mail/settings Per-user mail preferences| Layer | Tech |
|---|---|
| Frontend | Next.js 15 App Router, server components |
| OAuth | NextAuth + per-provider adapter (currently Gmail) |
| Storage | Postgres (Supabase) with RLS; mail_threads, mail_messages, oauth_tokens, oauth_token_access_log |
| Encryption | AES-256-GCM via lib/oauth-crypto.ts |
| Audit | withAudit({ module: 'mail' }) middleware |
| Provider abstraction | lib/message-providers/ โ extend with ~30 LOC for new provider |
๐ณ Plans
| Free | Standard | Advanced | Enterprise | |
|---|---|---|---|---|
| Connect 1 mail account | โ | โ | โ | โ |
| Connect multiple accounts | โ | โ | โ | โ |
| Spam blocker | โ | โ | โ | โ |
| Mail-to-task automation | โ | โ | โ | โ |
| Per-patient mail filing | โ | โ | โ | โ |
| Bulk archive / move / label | โ | โ | โ | โ |
| Custom IMAP / SMTP | โ | โ | โ | โ |
๐งฐ Setup Guide
A built-in modal walks the admin through:
- Click Connect Gmail on the
/chator/mailpage. - Approve the Google OAuth consent screen โ Synalux requests
gmail.readonly,gmail.send,gmail.modify. - Folder sync starts in the background (typically 30-90s for the first 1000 messages).
- Mail appears in the unified inbox; reply directly from the thread view.
For Outlook / Yahoo / custom IMAP support, watch the Roadmapย or contact sales.