
一个简单的MCP服务器,让你的AI代理通过SMTP发送邮件并附加文件。
概览
一个MCP(模型上下文协议)服务器,让你的AI助手通过SMTP发送邮件。 - — 发送快速邮件(文本或HTML);接受可选smtp_config- — 完全控制:CC/BCC、附件;接受可选smtp_config- — 发送前请验证您的SMTP设置;接受可选smtp_config 配置SMTP(见下一节),然后运行: 你可以用两种方式配置SMTP凭证——使用其中一种或两种。 复制示例并填写你的资历: 或者,通过客户端的环境块传递(见下文客户端配置)。 在任何工具调用中直接传递smtp_config——该调用忽略环境变量: 请使用下面的通用示例,调整客户端的顶层密钥和配置文件路径:
概述(AI 翻译)
一个MCP(模型上下文协议)服务器,让你的AI助手通过SMTP发送邮件。
特色
send_simple_email— 发送简短电子邮件(文本或HTML);接受可选smtp_configsend_custom_email— 完全控制:CC/BCC,附件;接受可选的smtp_configtest_smtp_connection— 发送前请核实您的SMTP设置;接受可选的smtp_config
快速启动
配置SMTP(见下一节),然后运行:
进行测试:
SMTP 配置
你可以用两种方式配置SMTP凭证——使用其中一种或两种。
选项A:环境变量
复制示例并填写你的资历:
或者,通过客户端的env块传递(见下文客户端配置)。
选项B:每次通话有效载荷
在任何工具调用中直接传递 smtp_config ——该调用忽略环境变量:
| 字段 | 类型 | 描述 |
|---|---|---|
host |
字符串 | SMTP服务器主机名 |
port |
整数 | SMTP服务器端口(通常为587) |
secure |
布尔 | 使用 SSL/TLS (false 用于 STARTTLS) |
username |
字符串 | 认证用户名 |
password |
字符串 | 认证密码 |
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Email MCP Server
An MCP (Model Context Protocol) server that lets your AI assistant send emails via SMTP.
Features
send_simple_email— Send a quick email (text or HTML); accepts optionalsmtp_configsend_custom_email— Full control: CC/BCC, attachments; accepts optionalsmtp_configtest_smtp_connection— Verify your SMTP settings before sending; accepts optionalsmtp_config
Quick Start
# Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh
cd email-mcp-server
uv sync --extra dev
Configure SMTP (see next section), then run:
# stdio transport (for MCP clients)
uv run python -m email_mcp_server.server
# Streamable HTTP transport (port 8000)
uv run python -m email_mcp_server.server --http
Run tests:
uv run pytest
SMTP Configuration
You can configure SMTP credentials in two ways — use one or both.
Option A: Environment variables
Copy the example and fill in your credentials:
cp env.example .env
# Required
SMTP_HOST=smtp.gmail.com
[email protected]
SMTP_PASS=your-app-password
[email protected]
# Optional (defaults shown)
# SMTP_PORT=587
# SMTP_SECURE=false
Alternatively, pass them via the client’s env block (see Client Configuration below).
Option B: Per-call payload
Pass smtp_config directly in any tool call — environment variables are ignored for that call:
{
"smtp_config": {
"host": "smtp.gmail.com",
"port": 587,
"secure": false,
"username": "[email protected]",
"password": "your-app-password",
"from_email": "[email protected]"
}
}
| Field | Type | Description |
|---|---|---|
host |
string | SMTP server hostname |
port |
integer | SMTP server port (usually 587) |
secure |
boolean | Use SSL/TLS (false for STARTTLS) |
username |
string | Auth username |
password |
string | Auth password |
from_email |
string | Sender email address |
Client Configuration
Claude Code
# stdio
claude mcp add email-server -- uv --directory /absolute/path/to/email-mcp-server run python -m email_mcp_server.server
# streamable HTTP (start the server first with --http)
claude mcp add --transport http email-server http://localhost:8000/mcp
JSON-based clients (Claude Desktop, Cursor, VS Code, Windsurf, Zed)
Use the generic example below and adjust the top-level key and config file path for your client:
{
"": {
"email-server": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/email-mcp-server", "run", "python", "-m", "email_mcp_server.server"],
"env": {
"SMTP_HOST": "smtp.gmail.com",
"SMTP_PORT": "587",
"SMTP_SECURE": "false",
"SMTP_USER": "[email protected]",
"SMTP_FROM": "[email protected]",
"SMTP_PASS": "your-app-password"
}
}
}
}
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →