Skip to main content
Glama

snagmail

Local fake SMTP server + MCP server. Your app's outgoing test mail never leaves localhost; OTP codes and verification links are extracted for you and handed to AI agents (MCP) or test suites (REST). Receive-only: it never sends mail. In-memory, no Docker, no database.

Quick start

npx snagmail
  • SMTP catcher: 127.0.0.1:1025

  • Web UI, REST API, MCP (/mcp): http://127.0.0.1:8025

Point your app at it:

SMTP_HOST=127.0.0.1
SMTP_PORT=1025
SMTP_SECURE=false

Related MCP server: TempMail OTP MCP Server

MCP setup

Stdio (the client launches snagmail itself; it also starts the SMTP catcher and UI):

claude mcp add --transport stdio snagmail -- npx -y snagmail --mcp-stdio

Claude Code .mcp.json, Cursor .cursor/mcp.json, Claude Desktop (all use mcpServers):

{ "mcpServers": { "snagmail": { "command": "npx", "args": ["-y", "snagmail", "--mcp-stdio"] } } }

VS Code .vscode/mcp.json (this file uses servers, not mcpServers):

{ "servers": { "snagmail": { "type": "stdio", "command": "npx", "args": ["-y", "snagmail", "--mcp-stdio"] } } }

HTTP (run npx snagmail yourself, then connect; use this when several windows/agents share one inbox):

claude mcp add --transport http snagmail http://127.0.0.1:8025/mcp

Claude Code .mcp.json:

{ "mcpServers": { "snagmail": { "type": "http", "url": "http://127.0.0.1:8025/mcp" } } }

Cursor .cursor/mcp.json:

{ "mcpServers": { "snagmail": { "url": "http://127.0.0.1:8025/mcp" } } }

VS Code .vscode/mcp.json:

{ "servers": { "snagmail": { "type": "http", "url": "http://127.0.0.1:8025/mcp" } } }

Only one snagmail can own the SMTP port. A second instance exits with an error; connect to the first one over HTTP instead.

MCP tools

Tool

Params

wait_for_email

to (* wildcard), subject_contains, timeout_ms (default 30000, max 300000), since_timestamp

list_emails

to, limit (default 10)

get_email

id, format: clean_text | html | raw

clear_inbox

to

wait_for_email returns the newest matching email already in the inbox, or waits for a new one. For repeat tests on the same address, call clear_inbox first, pass since_timestamp, or use a unique recipient. to matches the SMTP envelope recipient (so BCC works), case-insensitive.

Result: id, from, to, envelope_to, header_to, cc, subject, extracted_otp, action_links[{type,label,url}], clean_text, received_at. Link types: verify, reset_password, magic_link, unsubscribe, other.

CLI flags

--smtp-port <port>  SMTP port (default 1025)
--http-port <port>  Web UI, REST, /mcp port (default 8025)
--mcp-stdio         Serve MCP over stdio (all logs go to stderr)
--no-ui             Skip the HTTP server (only with --mcp-stdio)
--max-emails <n>    Emails kept in memory (default 200)

If the HTTP port is busy in --mcp-stdio mode, snagmail warns on stderr and keeps running without the UI.

REST API

Endpoint

GET /api/v1/emails?to=&search=&limit=

list (no bodies)

GET /api/v1/emails/wait?to=&subject_contains=&since_timestamp=&timeout_ms=

long poll; 408 on timeout

GET /api/v1/emails/:id

full email incl. html, raw

DELETE /api/v1/emails?to=

clear all or filtered

WS /ws

live feed (email, clear)

Example (CI): curl "http://127.0.0.1:8025/api/v1/emails/wait?to=qa@test.local&timeout_ms=10000"

Security

Binds to 127.0.0.1 only, validates Host/Origin, and the UI previews HTML in a script-less sandboxed iframe with remote loads blocked.

Dev

npm run dev · npm test · npm run build

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to create disposable email inboxes and automatically extract OTPs, magic links, and verification codes from incoming emails.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI coding agents to create disposable test inboxes, wait for and read incoming email, and extract confirmation links and one-time codes for sign-up, password-reset, and magic-link flows.
      6
      14 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Lets AI agents create real disposable email addresses, wait for incoming mail, and get verification codes and links back, so they can complete signups, logins and email-flow tests on their own. Codes and links are detected server-side, so no HTML parsing is needed. Requires an OpenInbox API key (Pro, Business or 7-Day Pass).
      8
      113 npm
      MIT