邮件发送服务器

Email MCP Server 是一个基于SMTP协议的邮件发送服务,允许AI助手通过SMTP发送邮件,支持简单邮件、自定义邮件(包括CC/BCC和附件)以及SMTP连接测试。

  • by egyptianego17
  • Python
  • 混合部署
  • 28 星标
  • 更新于
在 GitHub 查看 egyptianego17/email-mcp-server

使用说明

电子邮件MCP服务器

MCP(模型上下文协议)服务器,允许您的AI助手通过SMTP发送电子邮件。

特性

  • send_simple_email --快速发送电子邮件(文本或HTML);接受可选 smtp_config
  • send_custom_email --完全控制:CC/BCC、附件;接受可选 smtp_config
  • test_smtp_connection --发送前验证SMTP设置;接受可选 smtp_config

快速开始

# 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

配置SMTP(请参阅下一节),然后运行:

# 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

运行测试:

uv run pytest

SMTP配置

您可以通过两种方式配置SMTP凭据——使用一种或两种方式。

选项A:环境变量

复制示例并填写您的凭据:

cp env.example .env
# Required
SMTP_HOST=smtp.gmail.com
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
SMTP_FROM=your-email@gmail.com

# Optional (defaults shown)
# SMTP_PORT=587
# SMTP_SECURE=false

或者,通过客户的 env 块(请参阅下面的客户端配置)。

选项B:每次通话有效载荷

通过 smtp_config 在任何工具调用中,环境变量都会被忽略:

{
  "smtp_config": {
    "host": "smtp.gmail.com",
    "port": 587,
    "secure": false,
    "username": "your-email@gmail.com",
    "password": "your-app-password",
    "from_email": "your-email@gmail.com"
  }
}
字段 类型 描述
host string SMTP服务器主机名
port integer SMTP服务器端口(通常 587)
secure boolean 使用SSL/TLS(false 对于STARTTLS)
username string 身份验证用户名
password string 身份验证密码
from_email string 发件人电子邮件地址

客户端配置

克劳德代码

# 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的客户端(Claude Desktop、Cursor、VS Code、Windsurf、Zed)

使用下面的通用示例,调整客户端的顶级密钥和配置文件路径:

{
  "<top-level-key>": {
    "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": "your-email@gmail.com",
        "SMTP_FROM": "your-email@gmail.com",
        "SMTP_PASS": "your-app-password"
      }
    }
  }
}
客户端 配置文件路径 顶级密钥 注释
克劳德桌面 ~/Library/Application Support/Claude/claude_desktop_config.json mcpServers 视窗: %APPDATA%\Claude\...
光标 ~/.cursor/mcp.json mcpServers 或者 .cursor/mcp.json (项目)
VS代码 .vscode/mcp.json servers 添加 "type": "stdio" 在服务器条目内
风帆冲浪 ~/.codeium/windsurf/mcp_config.json mcpServers
Zed ~/.config/zed/settings.json context_servers

流式HTTP(任何客户端)

使用启动服务器 uv run python -m email_mcp_server.server --http那么:

客户端 配置
克劳德代码 claude mcp add --transport http email-server http://localhost:8000/mcp
克劳德桌面 { "type": "http", "url": "http://localhost:8000/mcp" }
光标 { "url": "http://localhost:8000/mcp" }
VS代码 { "type": "http", "url": "http://localhost:8000/mcp" }
风帆冲浪 { "serverUrl": "http://localhost:8000/mcp" }
Zed { "url": "http://localhost:8000/mcp" }

提供商设置

提供者 主机 备注
Gmail smtp.gmail.com 需要 应用程序密码 启用2FA
展望 smtp-mail.outlook.com 常规密码或应用程序密码
雅虎 smtp.mail.yahoo.com 需要启用2FA的应用程序密码
icloud smtp.mail.me.com 需要启用2FA的应用程序密码

所有提供商都使用端口 587 随着 SMTP_SECURE=false (开始)。

许可证

MIT许可证