Skip to content
gopkg-devPublic

About

Self-hosted mail hub: all your mailboxes on your own server, ready for AI agents via MCP and REST API

Resources

Stars

12 stars

Watchers

0 watching

Forks

Repository files navigation

DaMail logo

DaMail

All your mailboxes on your own server, ready for AI agents.

DaMail is a self-hosted mail hub. It syncs every mailbox you own into one place and adds AI triage and automation.
AI agents get scoped, auditable access to it through MCP and a REST API.

The name sounds like dame (だめ), Japanese for “nope”: no agent sends a single email without your OK, given per email or by granting it send.

Release Build Docker image License: MIT

Website · Documentation · Changelog · 简体中文


Why DaMail

  • One inbox for every account. DaMail works with Gmail, Outlook, iCloud, QQ Mail, NetEase 163, Tencent and Alibaba business mail, and any IMAP server. Mail syncs in real time and is threaded and searchable. Changes you make are written back to the mail server.
  • AI that works for you. It can sort mail, set priority, write summaries and pull out codes, bills and to-dos. It uses the model you choose: Claude, any OpenAI-compatible API, or a local model. AI is off by default.
  • Agents get only the access you grant. Claude Duet, ChatGPT dots, Grok Bot, Meta Muse, Claude Code, Cursor and other agents use credentials issued by DaMail. Each credential covers only the permissions and mailboxes you pick. By default, mail an agent writes waits for your approval.
  • Your data stays with you. You host it yourself. Mailbox credentials are encrypted with your own master key. HTML mail renders in a sandbox with remote images blocked. No third-party service sits in between.

Features

Mail IMAP IDLE push, Microsoft Graph, threading, cross-folder dedup, CJK-friendly search, rich-text compose, signatures, undo send, scheduled send
AI Mail analysis (category, priority, needs-reply, summary, extracted info), custom labels suggested from your mail, natural-language search, a chat assistant that cites sources, one-click translation, token usage and cost tracking
Automation Inbox rules with AI conditions and dry runs, notifications to Bark, WeCom, DingTalk, Feishu, Telegram or a webhook, daily and weekly reports, mail stats, awaiting-reply tracking, follow-up reminders
Subscriptions Find newsletters you rarely open, sorted by open rate, and unsubscribe in one click (RFC 8058) without visiting the sender's site
Open API MCP server (Streamable HTTP), REST API, scoped API keys, MCP OAuth for ChatGPT and other clients, HMAC-signed webhooks, audit log

Quick start

You need a machine with Docker and Docker Compose. Then run:

curl -fsSL https://damail.app/install.sh | sh

The installer asks which language to use (简体中文 or English). It then creates damail/, downloads docker-compose.yml, writes a .env with a random MASTER_KEY and database password, and starts DaMail. Open http://localhost:8787 to create the admin account and add your first mailbox.

If you already have a domain, pass it in:

curl -fsSL https://damail.app/install.sh | DAMAIL_PUBLIC_URL=https://mail.example.com sh

Back up damail/.env. Its MASTER_KEY encrypts your mailbox credentials. To upgrade, run the install command again; your .env is left as is, and database migrations run on startup.

The quick start guide covers installer options, manual setup with Docker Compose, HTTPS and reverse proxies.

Connect an AI agent

  1. In DaMail, go to Settings → API keys and create a key.
  2. Choose its permissions (read, organize, draft, send, automation) and the mailboxes it can use.
  3. Add DaMail to your client as shown below.

Claude Code

claude mcp add --transport http damail https://mail.example.com/mcp \
  --header "Authorization: Bearer dm_xxx"

Claude Desktop, Cursor and other MCP clients

{
  "mcpServers": {
    "damail": {
      "type": "http",
      "url": "https://mail.example.com/mcp",
      "headers": { "Authorization": "Bearer dm_xxx" }
    }
  }
}

ChatGPT connects through OAuth. Add https://mail.example.com/mcp as a custom connector, sign in to DaMail, and choose permissions and mailboxes on the consent page. Setup details are in ChatGPT and OAuth.

AI assistants. Proactive assistants such as Claude Duet, ChatGPT dots, Grok Bot and Meta Muse connect the same way, through their custom connector settings with OAuth. Once connected they can brief you on new mail, flag what needs a reply and draft answers for your approval. Setup for each assistant is in AI assistants.

An agent never sees tools it isn't allowed to use. Here is what happens when an agent sends the same test email with and without send:

Without send With send
Tools request_send request_send and send_draft
What happens The email goes to Drafts → Awaiting approval and is sent only after you approve it on the web The email is sent after SEND_DELAY_SEC seconds (10 by default), with no approval step
How you stop it Edit, approve or reject it Undo it within the delay window
Limits None needed Over OAuth, each authorization can send at most 10 emails per hour (adjustable in settings, 0 turns direct sending off). API keys have no hourly cap

Even with send, the MCP instructions tell agents to use request_send unless you explicitly ask them to send directly.

Documentation

The full documentation, in English and Chinese, is at damail.app.

Topic Pages
Getting started Introduction · Quick start · Configuration · Proxies · Upgrading
Using DaMail Mailboxes · Reading & sending · Subscriptions · Search syntax
AI features Models · Mail analysis · Labels · AI search · Assistant · Translation · Usage & cost
Automation Inbox rules · Notifications · Reports & stats · Follow-ups
AI agents AI assistants · MCP · ChatGPT and OAuth · REST API
Contributing Development · Releasing

How it works

flowchart LR
  subgraph Providers
    IMAP[IMAP / SMTP]
    Graph[Microsoft Graph]
  end
  subgraph DaMail
    Sync[Sync & send]
    Jobs[AI analysis · rules · reports]
    API[Web app · MCP · REST API]
  end
  DB[(PostgreSQL)]
  LLM[Model provider<br/>or local model]
  Agents[Claude · ChatGPT · Cursor]
  Notify[Bark · WeCom · DingTalk<br/>Feishu · Telegram · Webhook]

  IMAP <--> Sync
  Graph <--> Sync
  Sync --> DB
  Jobs <--> DB
  Jobs <--> LLM
  Jobs --> Notify
  API <--> DB
  Agents <-->|scoped key / OAuth| API
Loading

DaMail runs as one Node.js service with PostgreSQL. It ships as a single multi-arch Docker image for linux/amd64 and linux/arm64.

Development

You need Node.js 22+, pnpm and Docker.

git clone https://github.com/gopkg-dev/damail.git && cd damail
cp .env.example .env
docker compose -f docker-compose.dev.yml -p damail-dev up -d   # PostgreSQL + GreenMail test mail server
pnpm install
pnpm dev                                                         # API on :8787, web app on :5180
pnpm typecheck   # type-check the server and the web app
pnpm test        # server tests against a separate damail_test database

The GreenMail container provides local test accounts, so development never needs a real mailbox. The development guide covers the project layout and test data.

Contributing

Issues and pull requests are welcome.

  • Bug reports: include your DaMail version (shown under About), your mail provider and the steps to reproduce.
  • Larger changes: open an issue first so we can agree on the approach.
  • Commits: follow Conventional Commits, for example feat(scope): … or fix(scope): ….
  • Docs: the documentation lives in website/. Doc fixes are as welcome as code.

Security

Please do not report security issues in public issues. Use GitHub private vulnerability reporting instead, and we will reply as soon as we can.

License

MIT

About

Self-hosted mail hub: all your mailboxes on your own server, ready for AI agents via MCP and REST API

Resources

Stars

12 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages