关于
This skill assists developers in integrating, configuring, and troubleshooting Mailtrap for live email sending via Email API or SMTP. It covers transactional and bulk streams, including batch submissions, for wiring outbound mail from an application. Use it when building or debugging email-sending integrations.
快速安装
Claude Code
推荐npx skills add mailtrap/mailtrap-skills -a claude-code/plugin add https://github.com/mailtrap/mailtrap-skillsgit clone https://github.com/mailtrap/mailtrap-skills.git ~/.claude/skills/sending-emails在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Sending emails (Mailtrap)
Overview
Mailtrap sends live email over Email API (REST) or SMTP. Two streams apply for API/SMTP: Transactional (non-promotional, app-generated) and Bulk (promotional / marketing volume). Batch is not a third stream: it is how you submit many messages in one request on whichever stream matches the content. Campaigns are a separate product path for promotional mail to Mailtrap contacts. Pair this sheet with the Transactional / Bulk developer pages when building or debugging integrations (including with AI-assisted coding).
How to integrate (preference order)
Preferred order:
- Plugin or integration for the user's platform (no-code or minimal-config) where available
- Official SDK for your language when one exists (maintained clients, typed helpers, less room for URL/auth mistakes).
- HTTP Email API when there is no SDK or the SDK does not fit (direct
POSTto/api/sendor/api/batchwith JSON). - SMTP only when you really need it (legacy stack, host/platform that only speaks SMTP, or hard constraints that rule out HTTP).
Choosing how to send
| Approach | Use when |
|---|---|
| Transactional, single message | Email generated by your app (password resets, receipts, notifications, alerts). One logical message per POST https://send.api.mailtrap.io/api/send |
| Bulk | Promotional email to contacts that you manage on your side and send at volume through Mailtrap. Not the same as "batch": bulk is the stream, not the batch endpoint. |
| Batch | You have multiple different messages to hand off at the same time (up to 500 per request). Cuts HTTP overhead; can be applied to both transactional and bulk |
| Campaigns | Promotional email to recipients stored as Mailtrap contacts, using Mailtrap Campaigns (audiences, scheduling, reporting in the product). Recommended to avoid implementing contact management and email sending logic; requires UI setup before sends flow—this skill does not replace that workflow. |
Before generating SDK code: read the README of the relevant SDK repository linked in the SDKs section below for current method signatures, constructor options, and examples. Do not rely on memory.
Related skills: authorizing-api-requests (tokens, env vars, auth headers), using-email-templates (template UUID and variables), testing-with-sandbox (safe testing), setting-up-sending-domain (verification before send).
When not to use
- Sandbox only—capturing mail without delivery, reading messages in a sandbox (
testing-with-sandbox). - The main ask is webhooks, step-by-step Campaigns UI setup, or deliverability deep-dives.
- Exhaustive API reference—once the user's path is clear, link the official send docs for full schemas, optional fields, and edge cases.
Quick reference
Email API
| Stream | Send Endpoint | Batch Endpoint | Authorization Header |
|---|---|---|---|
| Transactional | POST https://send.api.mailtrap.io/api/send | POST https://send.api.mailtrap.io/api/batch | Authorization: Bearer $MAILTRAP_API_TOKEN |
| Bulk (promotional / marketing volume) | POST https://bulk.api.mailtrap.io/api/send | POST https://bulk.api.mailtrap.io/api/batch | Authorization: Bearer $MAILTRAP_API_TOKEN |
SMTP
| Setting | Transactional | Bulk |
|---|---|---|
| Host | live.smtp.mailtrap.io | bulk.smtp.mailtrap.io |
| Port | 587 (also 25, 2525, 465 with SSL) | 587 (also 25, 2525, 465 with SSL) |
| Username | api | api |
| Password | API token ($MAILTRAP_API_TOKEN) | API token ($MAILTRAP_API_TOKEN) |
Tokens
Use $MAILTRAP_API_TOKEN in either Authorization: Bearer ... or Api-Token: .... The same token works on both send.api.mailtrap.io and bulk.api.mailtrap.io as long as its scope covers the stream. Full guidance (scope, storage, rotation) lives in skill authorizing-api-requests.
Rate limits
| Scope | Limit | Window |
|---|---|---|
| Sending API (per token) | 150 requests | 10 seconds |
Use backoff on 429.
JSON body (non-template)
Typical fields include from, to, subject, and text and/or html. Optional: category, custom_variables. Exact request bodies: Transactional send and Bulk send.
Examples (curl)
Transactional send (send.api.mailtrap.io):
curl -X POST https://send.api.mailtrap.io/api/send \
-H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"from": {"email": "[email protected]", "name": "Your App"},
"to": [{"email": "[email protected]"}],
"subject": "Hello",
"text": "Plain text body"
}'
Bulk stream uses the same path and JSON shape on the bulk host (same env var; the token only needs bulk-stream scope):
curl -X POST https://bulk.api.mailtrap.io/api/send \
-H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"from": {"email": "[email protected]", "name": "Your App"},
"to": [{"email": "[email protected]"}],
"subject": "Promotional",
"html": "<p>HTML body</p>"
}'
Batch (array of messages; up to 500 per request — see API docs for full schema):
curl -X POST https://send.api.mailtrap.io/api/batch \
-H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"messages":[{"from":{"email":"[email protected]"},"to":[{"email":"[email protected]"}],"subject":"One","text":"..."}]}'
JSON body (template)
Use template_uuid and template_variables instead of raw text/html to use a template hosted by Mailtrap. Minimal example:
curl -X POST https://send.api.mailtrap.io/api/send \
-H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"from": {"email": "[email protected]", "name": "Your App"},
"to": [{"email": "[email protected]"}],
"template_uuid": "your-template-uuid",
"template_variables": {"user_name": "Jane"}
}'
See skill using-email-templates and the same API operations as non-template sends.
SDKs
Suppressions
Mailtrap automatically manages suppressions for addresses that hard bounce, report spam, or unsubscribe, and will not send emails to these suppressed recipients again. For details, see the Suppressions documentation.
Common mistakes
| Mistake | Fix |
|---|---|
| Confusing batch with bulk | Batch = many messages in one /api/batch request. Bulk = promotional stream/host and token |
| Promotional API mail on transactional host | Use bulk base URL and bulk token for promotional content you generate in code |
Bulk traffic on send.api.mailtrap.io | Promotional/bulk stream uses bulk.api.mailtrap.io |
| Using sandbox SMTP host for live sending | Live sending uses live.smtp.mailtrap.io or bulk.smtp.mailtrap.io |
| SMTP username is an email address | Username is api; password is the API token |
| Sending before domain is verified | Complete Sending Domains setup and compliance (see setting-up-sending-domain) |
| Guessing SDK API from memory | Read the SDK README and OpenAPI-linked examples; do not invent constructors or method names |
| Choosing SMTP first for a greenfield app | Prefer platform integration if one exists, then SDK, then HTTP API; SMTP only when necessary (see How to integrate) |
GitHub 仓库
常见问题
什么是 sending-emails Skill?
sending-emails 是一个 Claude Skill,作者为 mailtrap。Skill 将 Claude 按需加载的说明和资源打包,让 Claude 无需额外提示即可执行与 sending-emails 相关的任务。
如何安装 sending-emails?
使用本页的安装命令:将 sending-emails 作为插件添加到 Claude Code,或将其仓库克隆到 skills 目录,然后重启 Claude 以加载该 Skill。
sending-emails 属于哪个分类?
sending-emails 属于开发分类。
sending-emails 可以免费使用吗?
可以。sending-emails 已收录在 AIMCP,可免费安装。
相关推荐技能
这是一个本地搜索和索引的CLI工具,支持BM25、向量搜索和重排序功能。开发者可以用它快速索引本地文件(如Markdown文档)并进行混合搜索,特别适合代码库或文档的本地检索。它还提供MCP模式,能轻松集成到Claude开发环境中使用。
该Skill用于在当前会话中执行包含独立任务的实施计划,它会为每个任务分派一个全新的子代理并在任务间进行代码审查。这种"全新子代理+任务间审查"的模式既能保障代码质量,又能实现快速迭代。适合需要在当前会话中连续执行独立任务,并希望在每个任务后都有质量把关的开发场景。
mcporter Skill 让开发者能在Claude中直接管理和调用MCP服务器。它支持列出可用服务器、调用工具、处理OAuth认证以及管理服务器守护进程。开发者可以通过命令行式交互快速执行`mcporter list`查看服务器,或使用`mcporter call`直接调用工具,简化了MCP工作流程。
这是一个用于部署和编排Google Vertex AI ADK智能体的Claude Skill,专为构建生产级多智能体系统而设计。它支持通过A2A协议进行智能体通信,提供代码执行沙箱和记忆库功能,并能处理智能体发现与任务提交。当开发者需要部署ADK智能体或编排多智能体协作时,可使用此Skill来简化Vertex AI Agent Engine的部署流程。
