关于
This skill enables developers to test outbound email functionality by capturing messages in a safe sandbox environment instead of sending to real recipients. It's used for inspecting email content, running spam checks, and automating tests against a fake inbox during development or staging. The skill supports integration via SDKs, HTTP API, or SMTP when working with services like Mailtrap Email Sandbox.
快速安装
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/testing-with-sandbox在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Testing with Mailtrap Email Sandbox
Overview
Email Sandbox captures mail in sandboxes (test inboxes)—a test environment where messages are not delivered to real recipients. You can send to sandboxes using our SDKs, HTTP API, or SMTP, depending on your needs.
Before generating SDK code: read the README of the relevant SDK repository (see sending-emails) for current sandbox mode options, inbox id, and constructor flags. Do not rely on memory.
Related skills: authorizing-api-requests (sandbox token scope, env vars, account_id resolution), sending-emails (live sending hosts and streams), using-email-templates (preview template sends in sandbox).
When to use
- You want no real delivery: dev, staging, CI, or demos where mail must stay in a test inbox.
- You need to inspect what was sent: bodies, headers, attachments, or basic checks (e.g. spam report) via Sandbox / Testing API or the UI.
- You are automating tests against captured mail.
- You will only change SMTP settings so an existing app sends into a sandbox—no need for a framework-by-framework tutorial from this skill.
When not to use
- Live sends to real recipients (
sending-emails). - For full framework setup guides or detailed API references, link users to Mailtrap's Integration tab for SMTP/API details and the API docs for specifics—don't cover every framework or API field here.
Quick reference
API base
| Service | Send mail URL | Auth header examples |
|---|---|---|
| Email Testing API (REST) | https://sandbox.api.mailtrap.io/api/send/{inbox_id} | Authorization: Bearer $MAILTRAP_SANDBOX_API_TOKEN |
Tokens and account_id
Sandbox uses a separate token ($MAILTRAP_SANDBOX_API_TOKEN, Testing/Sandbox scope) — never reuse the live $MAILTRAP_API_TOKEN. The account_id in the example endpoints below is resolved at runtime via GET https://mailtrap.io/api/accounts. Full token scope, storage, and account_id resolution: see skill authorizing-api-requests.
When to use API vs SMTP
Use SMTP when testing apps that already send mail via SMTP (just update the host, port, and credentials). Use the HTTP API when building new integrations or your app can make HTTP requests; it's better for programmatic testing and automation.
SMTP settings (sandbox)
| Setting | Value |
|---|---|
| Host | sandbox.smtp.mailtrap.io |
| Ports | 2525 (default), 25, 465 (SSL), 587 |
| Username / Password | Per sandbox credentials from the Integration tab in the Mailtrap UI |
Never use sandbox credentials or endpoints in production. Messages will only be captured in the sandbox, not delivered.
Key parameters
- Inbox ID: Every sandbox (test inbox) has a unique inbox id, visible in the UI URL and needed for sending or REST API operations.
- Token scope: Use a token with permissions for the relevant project and test inbox.
Typical use cases
- Capture all outbound mail in dev, test, or staging (no real recipients).
- View, validate, and assert message headers, bodies, HTML, attachments, or spam score.
- Run integration or CI checks that read from the Email Sandbox API.
- Test Mailtrap templates by pointing API or SDK/SMTP at
sandbox.api.mailtrap.io/sandbox.smtp.mailtrap.iowith a valid inbox id.
Example API paths
Use API docs for details, but typical endpoints include:
| Operation | URL | Reference |
|---|---|---|
| List sandboxes | GET https://mailtrap.io/api/accounts/$MAILTRAP_ACCOUNT_ID/inboxes | Sandboxes API |
| List messages | GET https://mailtrap.io/api/accounts/$MAILTRAP_ACCOUNT_ID/inboxes/{inbox_id}/messages | Messages |
| Fetch a message | GET https://mailtrap.io/api/accounts/$MAILTRAP_ACCOUNT_ID/inboxes/{inbox_id}/messages/{id} | Message details |
| Send test email | POST https://mailtrap.io/api/accounts/$MAILTRAP_ACCOUNT_ID/inboxes/{inbox_id}/messages | Send test emails |
For template testing, see the Integration tab of your template and Handlebars.
SDKs
Official Mailtrap SDKs support sandbox/inbox operations and provide flags or methods to set test mode and inbox id. This allows you to use the same integration for both live sending and sandbox testing—simply change the mode or credentials depending on your environment (development, staging, or production). For install commands and language coverage, see Mailtrap developer documentation. Repository READMEs have the latest sandbox options:
Common mistakes
| Mistake | Fix/Explanation |
|---|---|
| Expecting real delivery from sandbox | Mail in the sandbox is never delivered to recipients |
| Using production API token for sandbox | Use a token with proper sandbox/testing scope, granting access to the target inbox |
| Forgetting inbox id parameter | Always supply the inbox id (from UI or Integration tab) to associate messages with the correct inbox |
| Mixing sandbox and transactional endpoints | Testing API (sandbox.api.mailtrap.io) is not the same as send.api.mailtrap.io (live sending)! |
Sandbox email address
Each sandbox (test inbox) has an address like [email protected] for inbound tests; plus-addressing can help isolate scenarios. See Email address per sandbox for limits and behavior.
GitHub 仓库
常见问题
什么是 testing-with-sandbox Skill?
testing-with-sandbox 是一个 Claude Skill,作者为 mailtrap。Skill 将 Claude 按需加载的说明和资源打包,让 Claude 无需额外提示即可执行与 testing-with-sandbox 相关的任务。
如何安装 testing-with-sandbox?
使用本页的安装命令:将 testing-with-sandbox 作为插件添加到 Claude Code,或将其仓库克隆到 skills 目录,然后重启 Claude 以加载该 Skill。
testing-with-sandbox 属于哪个分类?
testing-with-sandbox 属于测试分类。
testing-with-sandbox 可以免费使用吗?
可以。testing-with-sandbox 已收录在 AIMCP,可免费安装。
相关推荐技能
该Skill通过60+个学术基准测试(如MMLU、GSM8K等)评估大语言模型质量,适用于模型对比、学术研究及训练进度追踪。它支持HuggingFace、vLLM和API接口,被EleutherAI等行业领先机构广泛采用。开发者可通过简单命令行快速对模型进行多任务批量评估。
这个Claude Skill提供了关于Cloudflare Cron Triggers的完整知识库,用于通过cron表达式定时执行Workers。它支持配置周期性任务、维护作业和自动化工作流,并能处理常见的cron触发错误。开发者可以用它来设置定时任务、测试cron处理器,并集成Workflows和Green Compute功能。
该Skill为开发者提供了基于Playwright的本地Web应用测试工具集,支持自动化测试前端功能、调试UI行为、捕获屏幕截图和查看浏览器日志。它包含管理服务器生命周期的辅助脚本,可直接作为黑盒工具运行而无需阅读源码。适用于需要快速验证本地Web应用界面和交互功能的开发场景。
这个Skill用于开发分支完成后的集成决策,当代码实现完成且测试通过时,它会引导开发者选择合适的工作流。它首先验证测试状态,然后提供合并、创建PR或清理等结构化选项。核心价值在于确保代码质量的同时,标准化分支收尾流程。
