mail-smtp-mcp

mail-smtp-mcp

A TypeScript MCP server that enables LLMs to send outbound emails via SMTP with support for attachments and HTML content. It includes outcome-oriented tools for account validation and enforces strict security policies like recipient allowlists and size limits.

Category
访问服务器

README

mail-smtp-mcp

TypeScript MCP (stdio) server for sending email via SMTP with a compact, LLM-optimized tool surface.

Overview

This server exposes outcome-oriented tools to validate SMTP accounts and send outbound email with strict policy controls. Responses are JSON-encoded text and include:

  • summary: concise human-readable summary
  • data: structured payload aligned to the tool contract
  • _meta: optional metadata (e.g., policy limits)

Capabilities

Read-only

  • List configured SMTP accounts (non-secret metadata)
  • Verify SMTP connectivity/authentication (no email sent)

Send (gated)

  • Send outbound email with text/HTML bodies
  • Optional attachments (bounded)
  • dry_run to validate inputs and policy without sending

Tools

mail_smtp_list_accounts

List configured SMTP accounts.

mail_smtp_verify_account

Verify a configured SMTP account can connect/authenticate.

Inputs include:

  • account_id (default: default)

mail_smtp_send_message

Send or validate an outbound email via SMTP.

Inputs include:

  • account_id (default: default)
  • from (optional; falls back to account default)
  • to, cc, bcc (string or string[])
  • reply_to (optional)
  • subject (required; header-injection safe)
  • text_body and/or html_body (at least one required)
  • attachments (optional; base64 content)
  • dry_run (optional; default false)

Configuration

Account configuration is provided via environment variables. This server also loads a local .env file (if present) using dotenv. Do not commit secrets. An example is provided in .env.sample.

If you only configure the default account, you can omit account_id in tool calls; it defaults to default.

MAIL_SMTP_DEFAULT_HOST
MAIL_SMTP_DEFAULT_PORT=587
MAIL_SMTP_DEFAULT_SECURE=false
MAIL_SMTP_DEFAULT_USER
MAIL_SMTP_DEFAULT_PASS
MAIL_SMTP_DEFAULT_FROM

Multiple accounts are supported by replacing DEFAULT with an uppercase account ID:

MAIL_SMTP_WORK_HOST
MAIL_SMTP_WORK_USER
MAIL_SMTP_WORK_PASS

Send gate

Sending is disabled by default. Enable with:

MAIL_SMTP_SEND_ENABLED=true

Allowlist policy (optional)

If set, only allowlisted recipients/domains can be used:

MAIL_SMTP_ALLOWLIST_DOMAINS=example.com,example.org
MAIL_SMTP_ALLOWLIST_ADDRESSES=alice@example.com,bob@example.org

Policy/limits defaults

These defaults apply unless overridden via environment variables:

MAIL_SMTP_MAX_RECIPIENTS=10
MAIL_SMTP_MAX_MESSAGE_BYTES=2500000
MAIL_SMTP_MAX_ATTACHMENTS=5
MAIL_SMTP_MAX_ATTACHMENT_BYTES=2000000
MAIL_SMTP_MAX_TEXT_CHARS=20000
MAIL_SMTP_MAX_HTML_CHARS=50000
MAIL_SMTP_CONNECT_TIMEOUT_MS=10000
MAIL_SMTP_SOCKET_TIMEOUT_MS=20000

Response shape (JSON text)

Many MCP clients expect content items to be type: "text" (and do not accept a JSON content type). This server returns a single text content item whose text is a JSON object:

{
  "summary": "Sent message to 1 recipient(s).",
  "data": {
    "account_id": "default",
    "dry_run": false,
    "envelope": {
      "from": "me@example.com",
      "to": ["alice@example.com"]
    },
    "message_id": "<abc123@example.com>",
    "accepted": ["alice@example.com"],
    "rejected": []
  }
}

Usage

Run locally

pnpm install
pnpm dev

Build

pnpm build

Chat Application Integration (stdio spawn command)

Many MCP-enabled chat applications run stdio servers by spawning a process from an executable command. These are common ways to invoke this server:

Option 1: Run via npx (published package)

  • command: npx
  • args: -y mail-smtp-mcp

Option 2: Run from this repo (dev, no build)

  • command: pnpm
  • args: -C /Users/jonathan/Code/Projects/mail-smtp-mcp dev

Option 3: Run from this repo (built)

  1. Build once:

    pnpm -C /Users/jonathan/Code/Projects/mail-smtp-mcp build
    
  2. Spawn:

  • command: node
  • args: /Users/jonathan/Code/Projects/mail-smtp-mcp/dist/index.js

Option 4: Install globally (true executable)

  1. Install:

    pnpm -g add /Users/jonathan/Code/Projects/mail-smtp-mcp
    
  2. Spawn:

  • command: mail-smtp-mcp

Example MCP server config

Exact configuration keys vary by chat application, but the shape usually looks like:

{
  "command": "node",
  "args": ["mail-smtp-mcp/dist/index.js"],
  "env": {
    "MAIL_SMTP_DEFAULT_HOST": "smtp.example.com",
    "MAIL_SMTP_DEFAULT_USER": "me@example.com",
    "MAIL_SMTP_DEFAULT_PASS": "app-password-or-token",
    "MAIL_SMTP_SEND_ENABLED": "true"
  }
}

Quality gates

pnpm check

Notes

  • Sending is gated by MAIL_SMTP_SEND_ENABLED=true.
  • Use dry_run to validate payloads without sending.
  • Inputs reject header injection characters and enforce size limits.
  • Do not log or return credentials; outputs contain non-secret metadata only.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选