跳过安装。2 分钟内即可运行。
在 cloud.anythingmcp.com 开始免费试用,一键添加 Mailtrap,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。
摘要
在任意 AI 智能体中使用 Mailtrap 账户:发送事务性、批量和群发邮件,在 Email Sandbox 中测试并查看垃圾邮件和 HTML 报告,管理发信域名、抑制列表和模板,在邮件日志中跟踪每封已发送的邮件,查看发送统计,并管理 Email Marketing 的联系人、列表和营销活动。只需一个 API 令牌;不可撤销的删除操作在安装时关闭。
试试这样问
Mailtrap 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Mailtrap、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
Mailtrap + Cursor
在任意 AI 智能体中使用 Mailtrap 账户:发送事务性、批量和群发邮件,在 Email Sandbox 中测试并查看垃圾邮件和 HTML 报告,管理发信域名、抑制列表和模板,在邮件日志中跟踪每封已发送的邮件,查看发送统计,并管理 Email Marketing 的联系人、列表和营销活动。只需一个 API 令牌;不可撤销的删除操作在安装时关闭。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
MAILTRAP_API_TOKEN
步骤 1 — 获取凭证
设置大约需要 3 分钟。你需要一个 Mailtrap 账户。
- 在 Mailtrap 中打开 Settings、API Tokens(https://mailtrap.io/api-tokens)并创建一个令牌。为它授予发信域名(用于发送、统计、日志和抑制列表)、沙箱或项目(用于 Email Sandbox)以及(如果使用)Email Marketing 的访问权限。修改抑制列表需要管理员权限。
- 把它粘贴到
MAILTRAP_API_TOKEN。它以Authorization: Bearer <token>发送,在你重置之前不会过期。 - 安装连接器并运行
mailtrap_list_accounts:它会显示账户和你的访问级别(1000 owner、100 admin、10 viewer),并确认令牌有效。一个令牌只属于一个账户,所有调用都作用于该账户,因此不需要账户 ID。 - 真实发送需要已验证的发信域名(
mailtrap_list_sending_domains);Email Sandbox 不需要域名也能使用。
Mailtrap 的各个功能使用不同的主机,连接器会为每个工具选择正确的主机:https://mailtrap.io 用于管理和报告,https://send.api.mailtrap.io 用于事务性发送,https://bulk.api.mailtrap.io 用于 Bulk 流,https://sandbox.api.mailtrap.io 用于向沙箱发送测试邮件。
发送:mailtrap_send_email 发送一封事务性邮件,最多 1000 个收件人;mailtrap_send_batch_emails 一次调用最多发送 500 封不同的邮件(最大 50 MB)。营销邮件和其他群发邮件通过 Bulk 流发送,使用 mailtrap_send_bulk_email 和 mailtrap_send_bulk_batch_emails,把推广流量与事务性邮件分开。内容可以是 text、html 或两者,也可以是已保存的模板:传入 template_uuid(mailtrap_list_templates 中的 uuid,不是数字 ID)和 template_variables,并省略 subject、text、html 和 category。from_email 必须属于已验证的发信域名;to、cc 和 bcc 是 {"email", "name"} 列表;附件以 Base64 放在 content 中。每次发送都会进入真实收件箱,所以 AI 会先向你展示收件人、发件人、主题和内容,等你确认。发送会返回 message_ids,每个收件人一个。批量调用即使有单封邮件失败也返回 200:AI 会检查 responses 中每一项的 success 和 errors。
Email Sandbox:mailtrap_send_sandbox_email 发送的测试邮件会被沙箱拦截,永远不会投递,是试用模板或新内容的安全方式。随后 AI 会读取被拦截的邮件(mailtrap_list_sandbox_messages、mailtrap_get_sandbox_message),以纯文本、预览 HTML、HTML 源码或原始 MIME 形式查看正文,查看邮件头、附件、带分数和命中规则的 SpamAssassin 报告,以及显示哪些邮件客户端不支持哪些元素和 CSS 属性的 HTML 检查。它还能列出项目和沙箱并创建沙箱;任何返回中都不包含 SMTP 凭据。
域名和送达率:列出和读取发信域名,包括需要发布的 DNS 记录(SPF、DKIM、DMARC、return path)及其验证状态,添加域名,并把 DNS 设置说明通过邮件发给负责 DNS 的人。被抑制的地址(硬退信、退订、垃圾邮件投诉、手动导入)会连同导致抑制的邮件一起列出;mailtrap_create_suppression 可停止向某个地址发送。查看单封邮件时,mailtrap_list_email_logs 可按收件人、状态、事件、分类和发送时间筛选,mailtrap_get_email_log 显示其投递、打开、点击和退信事件以及服务商的响应。mailtrap_get_sending_stats 给出一段时间的汇总,mailtrap_get_sending_stats_grouped 按域名、分类、邮箱服务商或天拆分,mailtrap_get_billing_usage 显示相对于套餐的用量。
模板:列出、读取、创建和更新模板。变量使用 Handlebars,例如 {{user_name}};更新后发送的邮件使用新版本。
Email Marketing:带状态、列表和字段的联系人(按 ID 或邮箱创建、读取和更新;为自动化和细分记录 purchase 等自定义事件;按邮箱匹配导入最多 50,000 个联系人,并用 mailtrap_get_contact_import 跟踪),联系人列表和联系人字段(作为 fields 键使用的合并标签)。营销活动:mailtrap_create_campaign 总是创建草稿,mailtrap_update_campaign 修改草稿,mailtrap_schedule_campaign 设置最多一个月后的发送时间,mailtrap_start_campaign 立即发送,mailtrap_cancel_campaign 把已排程的活动退回草稿,mailtrap_get_campaign_stats 显示结果。排程和启动会向全部受众发邮件:AI 会先和你确认活动、受众和时间。只添加同意接收邮件的联系人;不想再给某人发邮件时,把他退订(unsubscribed: true),而不是删除。
安装时关闭:mailtrap_delete_suppression(该地址将重新收到邮件)、mailtrap_clean_sandbox(删除沙箱中的所有邮件)和 mailtrap_delete_contact。它们无法撤销,因此团队需要时由工作区管理员开启。
数据格式:域名、沙箱、邮件、模板、列表和营销活动的 ID 是整数;联系人、抑制记录和邮件日志中的邮件使用 UUID。时间为 UTC 的 ISO 8601 格式。统计中的比率是小数(0.25 = 25%),统计日期为 YYYY-MM-DD。
分页:联系人把 pagination.next_token 作为 token 传入,直到它为 null;营销活动把 pagination.next_token 中的页码作为 token。邮件日志把 next_page_cursor 作为 search_after 传入。抑制记录每页 1000 条,把最后一条的 id 作为 last_id。沙箱邮件每页 30 条,使用 page 或把最后一封邮件的 ID 作为 last_id。
限制:每个令牌每 10 秒 150 次请求;联系人每分钟 200 次,统计和抑制列表每分钟 10 次,列出邮件日志每个账户每分钟 60 次。
常见错误:401 Incorrect API token 表示令牌错误,或没有该域名或沙箱的访问权限。403 表示缺少权限:在 Settings、API Tokens 中编辑令牌。404 表示未知 ID。422 表示输入无效,原因在 errors 中,例如发件人不在已验证域名上,或营销活动已不是草稿。429 表示触发速率限制:稍等后重试。
该连接器不删除发信域名、沙箱、模板或营销活动,也不返回沙箱的 SMTP 凭据。
步骤 2 — 安装 adapter
curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d
步骤 3 — 在 Cursor 中添加连接器
你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(
https://cloud.anythingmcp.com/mcp/…)。本指南中出现YOUR_SERVER_ID的地方都用它替换。
Cursor 从 ~/.cursor/mcp.json 读取 MCP 服务器。添加以下条目:
{
"mcpServers": {
"anythingmcp": {
"url": "https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID",
"headers": { "X-API-Key": "YOUR_MCP_API_KEY" }
}
}
}
- 在 AnythingMCP 的 MCP Servers → 你的服务器 → API keys 中创建 MCP API 密钥,并用它替换
YOUR_MCP_API_KEY。 - 保存文件并重启 Cursor。
- 打开 Cursor → Settings → MCP,确认
anythingmcp已列出并处于已连接状态。 - 开始对话,智能体现在可以调用
Mailtrap的工具。
可用工具
| Tool | What it does |
|---|---|
mailtrap_list_accounts | Mailtrap accounts the API token can reach, with id, name and access_levels (1000 owner, 100 admin, 10 viewer) |
mailtrap_get_billing_usage | Usage of the current billing cycle: plan names and sent or stored message counts against their limits for Email Sending, Email Sandbox and… |
mailtrap_send_email | Send one transactional email through the Email API (send.api.mailtrap.io): to up to 1000 recipients, with text and/or HTML, or from a… |
mailtrap_send_batch_emails | Send up to 500 different transactional emails in one call (send.api.mailtrap.io/api/batch): shared fields in base, one entry per message in… |
mailtrap_send_bulk_email | Send one marketing or bulk email through the Bulk stream (bulk.api.mailtrap.io), which keeps promotional traffic apart from transactional… |
mailtrap_send_bulk_batch_emails | Send up to 500 different bulk (marketing) emails in one call through the Bulk stream (bulk.api.mailtrap.io/api/batch) |
mailtrap_list_sending_domains | Sending domains of the account with their id, DNS verification and compliance status and tracking settings |
mailtrap_get_sending_domain | One sending domain with the DNS records to publish (SPF, DKIM, DMARC, return path) and whether each is verified, plus compliance status and… |
mailtrap_create_sending_domain | Add a sending domain |
mailtrap_send_domain_setup_instructions | Email the DNS setup instructions of a sending domain to someone, e.g. the person who manages DNS |
mailtrap_list_suppressions | Addresses Mailtrap no longer sends to (hard bounce, unsubscription, spam complaint, manual import), up to 1000 per call, with the message… |
mailtrap_create_suppression | Stop sending to an address on one domain and stream |
mailtrap_delete_suppression | Remove a suppression so the address receives email again |
mailtrap_get_sending_stats | Sending totals for a date range: delivery, bounce, open, click and spam counts and rates, optionally limited to domains, streams… |
mailtrap_get_sending_stats_grouped | The same sending stats split by sending domain, category, recipient mailbox provider or day |
mailtrap_list_email_logs | Sent messages of the account, newest first, with status, recipient, subject, category, opens and clicks |
mailtrap_get_email_log | One sent message with its delivery events (delivery, open, click, bounce with the provider response), custom variables, template and a link… |
mailtrap_list_sandbox_projects | Email Sandbox projects with the sandboxes (test inboxes) in each |
mailtrap_list_sandboxes | All sandboxes (test inboxes) with id, name, project, message and unread counts and the sandbox email address |
mailtrap_get_sandbox | One sandbox: name, project, message counts, size limits, SMTP host and ports and its email address |
mailtrap_list_sandbox_messages | Messages caught in a sandbox, newest first, 30 per page: id, subject, sender, recipient, sent time, size and read state (SMTP details and… |
mailtrap_get_sandbox_message | One sandbox message: sender, recipient, subject, size, SMTP details and blacklist report summary |
mailtrap_get_sandbox_message_body | The body of a sandbox message: txt (plain text), html (sanitized for preview), htmlsource (the HTML as sent) or raw (the whole MIME message) |
mailtrap_get_sandbox_message_headers | The mail headers of a sandbox message (From, To, Subject, Message-ID, List-Unsubscribe, ...) |
mailtrap_get_sandbox_spam_report | SpamAssassin report of a sandbox message: total score, threshold and the rules that matched |
mailtrap_get_sandbox_html_analysis | HTML check of a sandbox message: which elements and CSS properties are unsupported by which email clients, with an overall support score |
mailtrap_list_sandbox_attachments | Attachments of a sandbox message with filename, content type, size and download path |
mailtrap_send_sandbox_email | Send a test email into a sandbox (sandbox.api.mailtrap.io): it is caught there and never reaches the recipients, so it is safe for trying… |
mailtrap_create_sandbox | Create a sandbox (test inbox) in a project; the answer carries its id and email address, SMTP credentials left out |
mailtrap_clean_sandbox | Delete every message in a sandbox |
mailtrap_list_contacts | Email Marketing contacts, 25 per page by default (at most 50), with id, email, status, list ids and fields |
mailtrap_get_contact | One contact by id or email: status, lists, fields and timestamps |
mailtrap_create_contact | Add a contact, optionally with fields (by merge tag) and lists |
mailtrap_update_contact | Change a contact: email, fields, list membership or subscription status |
mailtrap_delete_contact | Delete a contact for good, e.g. on an erasure request |
mailtrap_create_contact_event | Record a custom event for a contact (e.g. purchase, trial_started) with parameters, for automations and segments |
mailtrap_list_contact_lists | Contact lists with id and name; search filters by the start of the name |
mailtrap_create_contact_list | Create an Email Marketing contact list; add contacts with list_ids or list_ids_included afterwards |
mailtrap_list_contact_fields | Contact fields with id, name, data type and the merge tag used in contact fields and templates |
mailtrap_import_contacts | Create or update up to 50,000 contacts in one asynchronous import, matched by email |
mailtrap_get_contact_import | Status of a contact import (created, started, finished, failed) with the counts of created and updated contacts and those over the plan… |
mailtrap_list_templates | Email templates of the account with id, uuid (used to send), name, category and subject |
mailtrap_get_template | One email template with subject, HTML and text body (Handlebars variables such as {{user_name}}) |
mailtrap_create_template | Create an email template |
mailtrap_update_template | Change an email template; only the fields you pass change |
mailtrap_list_campaigns | Email Marketing campaigns, newest first, with id, name, state and schedule |
mailtrap_get_campaign | One campaign: state, sender, audience lists and segments, delivery mode, template and schedule |
mailtrap_get_campaign_stats | Results of a campaign: delivered, opened, clicked, bounced, spam and unsubscribed counts and rates, optionally for a date window |
mailtrap_create_campaign | Create a campaign as a draft: sender, audience, subject and design |
mailtrap_update_campaign | Change a draft campaign; only the fields you pass change |
mailtrap_schedule_campaign | Schedule a draft campaign to go out at a set time, at most one month ahead |
mailtrap_start_campaign | Start sending a draft campaign now to its whole audience |
mailtrap_cancel_campaign | Cancel a scheduled campaign before it goes out; it goes back to draft and can be edited again |
示例提示
- “今天早上发给 [email protected] 的订单确认邮件送达了吗?给我看它的事件。”
- “把这个新的欢迎模板发到我们的测试沙箱,告诉我它的垃圾邮件分数,以及哪些邮件客户端对这段 HTML 有问题。”
- “上周我们的送达率、退信率和垃圾邮件率是多少?按邮箱服务商拆分。”
- “我们发信域名的哪些 DNS 记录还没有通过验证?”
- “用 11 月新闻邮件模板为客户列表创建一个营销活动草稿,排程前先给我看受众。”
FAQ
Cursor 免费套餐支持自定义 MCP 服务器吗? 支持,Hobby、Pro 和 Business 套餐均可使用 MCP。
下一步
这份指南对你有帮助吗?