Skip to main content
Glama
Email Sender MCP Server

Email Sender MCP Server

by wyccywwyc

📧 邮件发送 MCP 服务器

基于 email_sender.py 工具类构建的邮件发送 MCP 服务器,支持通过 Model Context Protocol 发送邮件。

✨ 功能特性

  • ✅ 发送简单邮件(单个收件人)

  • ✅ 发送完整邮件(支持多个收件人、附件、CC、BCC)

  • ✅ 支持纯文本和 HTML 格式

  • ✅ 支持自定义 SMTP 配置

  • ✅ 支持常用邮箱预设配置(163、QQ、Gmail、Outlook等)

  • ✅ 从环境变量读取配置

Related MCP server: 126 Email MCP Server

🚀 快速开始

1. 安装依赖

uv sync

2. 配置环境变量

创建 .env 文件或设置环境变量:

# SMTP 服务器配置
export SMTP_SERVER=smtp.qq.com
export SMTP_PORT=587
export SENDER_EMAIL=your-email@qq.com
export SENDER_PASSWORD=your-authorization-code
export USE_TLS=true
export USE_SSL=false

3. 在 Cursor 中配置 MCP 服务器

在 Cursor 的设置中添加 MCP 服务器配置:

{
  "mcpServers": {
    "email-sender": {
      "command": "uv",
      "args": [
        "--directory",
        "/Users/wangyichao/study/mcp/emailMCP",
        "run",
        "main.py"
      ],
      "env": {
        "SMTP_SERVER": "smtp.qq.com",
        "SMTP_PORT": "587",
        "SENDER_EMAIL": "your-email@qq.com",
        "SENDER_PASSWORD": "your-authorization-code",
        "USE_TLS": "true",
        "USE_SSL": "false"
      }
    }
  }
}

📋 可用工具

1. send_simple_email - 发送简单邮件

发送单个收件人的简单邮件。

参数:

  • receiver_email (str): 收件人邮箱地址

  • subject (str): 邮件主题

  • content (str): 邮件内容

  • content_type (str, 可选): 内容类型,'plain' 或 'html',默认为 'plain'

示例:

send_simple_email(
    receiver_email="recipient@example.com",
    subject="测试邮件",
    content="这是一封测试邮件",
    content_type="plain"
)

2. send_email - 发送完整邮件

发送支持多个收件人、附件、CC、BCC 的完整邮件。

参数:

  • receiver_emails (List[str]): 收件人邮箱地址列表

  • subject (str): 邮件主题

  • content (str): 邮件内容

  • content_type (str, 可选): 内容类型,'plain' 或 'html',默认为 'plain'

  • attachments (List[str], 可选): 附件文件路径列表

  • cc_emails (List[str], 可选): 抄送邮箱地址列表

  • bcc_emails (List[str], 可选): 密送邮箱地址列表

示例:

send_email(
    receiver_emails=["user1@example.com", "user2@example.com"],
    subject="重要通知",
    content="<h1>这是HTML邮件</h1><p>内容支持HTML格式</p>",
    content_type="html",
    cc_emails=["cc@example.com"],
    attachments=["/path/to/file.pdf"]
)

3. send_email_with_custom_config - 使用自定义配置发送

使用自定义 SMTP 配置发送邮件,不依赖环境变量。

参数:

  • receiver_emails (List[str]): 收件人邮箱地址列表

  • subject (str): 邮件主题

  • content (str): 邮件内容

  • smtp_server (str): SMTP服务器地址

  • smtp_port (int): SMTP端口

  • sender_email (str): 发件人邮箱

  • sender_password (str): 发件人密码或授权码

  • content_type (str, 可选): 内容类型,默认为 'plain'

  • use_tls (bool, 可选): 是否使用TLS,默认为 False

  • use_ssl (bool, 可选): 是否使用SSL,默认为 False

  • attachments (List[str], 可选): 附件文件路径列表

  • cc_emails (List[str], 可选): 抄送邮箱地址列表

  • bcc_emails (List[str], 可选): 密送邮箱地址列表

4. get_smtp_configs - 获取常用邮箱配置

获取常用邮箱的 SMTP 配置信息。

返回: JSON 格式的配置信息

5. get_current_config - 获取当前配置

获取当前使用的 SMTP 配置(从环境变量读取)。

返回: JSON 格式的配置信息(密码已隐藏)

📝 常用邮箱配置

QQ 邮箱

SMTP_SERVER=smtp.qq.com
SMTP_PORT=587
USE_TLS=true
USE_SSL=false

或使用 SSL:

SMTP_SERVER=smtp.qq.com
SMTP_PORT=465
USE_TLS=false
USE_SSL=true

注意: 需要使用授权码,不是登录密码。在 QQ 邮箱设置中开启 SMTP 服务并生成授权码。

163 邮箱

SMTP_SERVER=smtp.163.com
SMTP_PORT=25
USE_TLS=false
USE_SSL=false

或使用 SSL:

SMTP_SERVER=smtp.163.com
SMTP_PORT=465
USE_TLS=false
USE_SSL=true

Gmail

SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
USE_TLS=true
USE_SSL=false

注意: Gmail 需要使用应用专用密码,不是普通密码。

Outlook

SMTP_SERVER=smtp-mail.outlook.com
SMTP_PORT=587
USE_TLS=true
USE_SSL=false

🔧 本地测试

直接运行服务器进行测试:

uv run main.py

📚 相关文件

  • email_sender.py: 邮件发送工具类

  • main.py: MCP 服务器主文件

  • pyproject.toml: 项目配置文件

⚠️ 注意事项

  1. 密码安全: 不要在代码中硬编码密码,使用环境变量或配置文件

  2. 授权码: 大多数邮箱服务商需要使用授权码而不是登录密码

  3. 端口选择:

    • 端口 25: 通常不需要加密(可能被某些网络阻止)

    • 端口 587: 使用 STARTTLS(推荐)

    • 端口 465: 使用 SSL/TLS

  4. 附件路径: 附件文件路径必须是绝对路径或相对于工作目录的路径

🐛 故障排除

认证失败

  • 检查邮箱和密码/授权码是否正确

  • 确认是否使用了授权码而不是登录密码

  • 检查 SMTP 服务是否已开启

连接失败

  • 检查 SMTP 服务器地址和端口是否正确

  • 确认网络连接正常

  • 检查防火墙设置

发送失败

  • 检查收件人邮箱地址格式是否正确

  • 确认附件文件路径存在且可读

  • 查看错误信息中的详细提示

📄 许可证

MIT License

Available Tools

5 tools
get_current_configB

获取当前使用的SMTP配置(从环境变量读取)

Returns: 当前配置信息

Inputs: no named parameters. Returns: result

get_smtp_configsB

获取常用邮箱的SMTP配置信息

Returns: 常用邮箱SMTP配置信息(JSON格式)

Inputs: no named parameters. Returns: result

send_emailB

发送完整邮件(支持多个收件人、附件、CC、BCC)

Args: receiver_emails: 收件人邮箱地址列表 subject: 邮件主题 content: 邮件内容(纯文本或HTML) content_type: 内容类型,'plain' 表示纯文本,'html' 表示HTML格式 attachments: 附件文件路径列表(可选) cc_emails: 抄送邮箱地址列表(可选) bcc_emails: 密送邮箱地址列表(可选)

Returns: 发送结果信息

Inputs: receiver_emails (required), subject (required), content (required), content_type, +3 more. Returns: result

send_email_with_custom_configB

使用自定义SMTP配置发送邮件

Args: receiver_emails: 收件人邮箱地址列表 subject: 邮件主题 content: 邮件内容 smtp_server: SMTP服务器地址(如:smtp.qq.com, smtp.gmail.com) smtp_port: SMTP端口(25/465/587) sender_email: 发件人邮箱 sender_password: 发件人密码或授权码 content_type: 内容类型,'plain' 或 'html' use_tls: 是否使用TLS(端口587通常需要) use_ssl: 是否使用SSL(端口465通常需要) attachments: 附件文件路径列表(可选) cc_emails: 抄送邮箱地址列表(可选) bcc_emails: 密送邮箱地址列表(可选)

Returns: 发送结果信息

Inputs: receiver_emails (required), subject (required), content (required), smtp_server (required), +9 more. Returns: result

send_simple_emailB

发送简单邮件(单个收件人,无附件)

Args: receiver_email: 收件人邮箱地址 subject: 邮件主题 content: 邮件内容(纯文本或HTML) content_type: 内容类型,'plain' 表示纯文本,'html' 表示HTML格式

Returns: 发送结果信息

Inputs: receiver_email (required), subject (required), content (required), content_type. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 5 tools

    Disambiguation4/5

    Most tools have distinct purposes, but send_email and send_simple_email overlap significantly in functionality. send_simple_email is essentially a subset of send_email, which could lead to confusion about when to use each. The configuration tools (get_current_config, get_smtp_configs) and custom config tool (send_email_with_custom_config) are clearly differentiated.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case, making them predictable and readable. The naming convention is uniform across all five tools, with clear action verbs (get, send) followed by descriptive nouns.

    Tool Count5/5

    Five tools is well-scoped for an email sending server, covering configuration retrieval, standard email sending, simple email sending, and custom configuration sending. Each tool serves a distinct purpose without unnecessary duplication or bloat.

    Completeness4/5

    The toolset covers core email sending workflows comprehensively, including configuration management and flexible sending options. A minor gap exists in lacking tools for managing sent emails (e.g., list_sent_emails, delete_email) or handling email templates, but agents can still accomplish basic email tasks effectively.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables sending emails via SMTP with template management, supporting multiple SMTP configurations, template creation with variable substitution, and bulk email sending with rate limiting.
      6
      737 npm
      25
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables sending emails through 126 mailbox SMTP service with support for plain text/HTML content, CC/BCC recipients, and secure SSL/TLS connections.
      1
      ISC
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI to send, read, search, delete and reply to emails through SMTP or Gmail API, supporting common email services like QQ, 163, Gmail and Outlook with HTML/text formats and attachments.
      1
      ISC

    Appeared in Searches