mailtrap-email-integration
Skill này làm gì
Công cụ này giúp bạn tự động gửi email từ ứng dụng, như email xác nhận đăng ký hoặc đặt lại mật khẩu, bằng dịch vụ Mailtrap. Nó đảm bảo email thử nghiệm không đến tay người thật và email gửi cho khách hàng hoạt động đúng.
Khi nào nên dùng
- ✓Khi bạn cần gửi email tự động, ví dụ email xác nhận đăng ký.
- ✓Để kiểm tra xem email thử nghiệm có đến nơi đúng không mà không làm phiền ai.
- ✓Khi thiết lập gửi email lần đầu trong một dự án.
Liên kết skill
https://github.com/affaan-m/ECC/blob/main/skills/mailtrap-email-integration/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm sao để thiết lập gửi email thử nghiệm bằng Mailtrap Sandbox?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ dùng API của Mailtrap để gửi email. Khi thử nghiệm, nó dùng một “sandbox” để thu nhận email. Với email thật, nó dùng một điểm cuối khác sau khi bạn đã xác minh tên miền email.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Mailtrap Email Integration
Patterns for adding transactional email sending to an application using Mailtrap's Email API and Sandbox, covering authentication, environment separation, and common delivery pitfalls.
When to Activate
- Implementing a "send email" feature (signup confirmation, password reset, notifications, receipts)
- Debugging why emails aren't arriving in dev/staging
- Setting up a project's first email-sending integration
- Reviewing code that calls an email API directly without sandbox separation
Core Concepts
Sandbox vs. Production separation. Mailtrap provides a Sandbox API that captures emails without delivering them, used for dev/staging so test emails never reach real inboxes. Production sending uses a separate, verified-domain endpoint. Never point a dev environment at the production sending endpoint.
Authentication. Requests use a Bearer token in the Authorization header. Tokens are scoped per project; sandbox and production typically use different tokens.
Domain verification. Production sending requires verifying a sending domain via DNS records (SPF, DKIM, DMARC) before Mailtrap will deliver to real recipients. Skipping this causes silent delivery failures or spam-folder placement.
Code Examples
// Sending via Mailtrap's Email API (production)
async function sendEmail(to: string, subject: string, html: string) {
const response = await fetch("https://send.api.mailtrap.io/api/send", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.MAILTRAP_API_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: { email: "no-reply@yourverifieddomain.com", name: "Your App" },
to: [{ email: to }],
subject,
html,
}),
});
if (!response.ok) {
throw new Error(`Email send failed: ${response.status}`);
}
return response.json();
}
// Same call, routed to Sandbox in non-production environments
const MAILTRAP_ENDPOINT = process.env.NODE_ENV === "production"
? "https://send.api.mailtrap.io/api/send"
: `https://sandbox.api.mailtrap.io/api/send/${process.env.MAILTRAP_INBOX_ID}`;
Anti-Patterns
| Anti-Pattern | Why It's a Problem | Instead |
|---|---|---|
| Using the production sending endpoint in dev/test | Real test emails reach real inboxes, risking spam complaints and leaked test data | Route non-production environments to the Sandbox endpoint |
| Hardcoding API tokens in source | Credential leak risk if committed to version control | Load tokens from environment variables / secrets manager |
| Sending before domain verification completes | Emails silently fail or land in spam | Verify SPF/DKIM/DMARC records before enabling production sending |
| No retry/error handling on send failures | Silent notification failures (e.g., user never gets password reset email) | Check response status, log failures, surface actionable errors |
Best Practices
- Keep sandbox and production tokens in separate environment variables, never share one token across environments
- Verify sending domain DNS records before any production launch involving email
- Log delivery failures with enough context to debug (recipient, template, timestamp, response code)
- Treat email sending as a fallible network call: wrap in try/catch, never assume success
Related Skills
api-and-interface-design, security-and-hardening, ci-cd-and-automation
Câu hỏi thường gặp
Mailtrap “Sandbox” là gì?
Đó là môi trường thử nghiệm nhận mọi email được gửi qua nó, mà không chuyển đến người nhận thật. Nó lý tưởng để kiểm thử mà không gửi email thật.
Tại sao tôi cần xác minh tên miền?
Để gửi email đến khách hàng thật, Mailtrap cần xác nhận bạn sở hữu tên miền mà email được gửi đi. Điều này giúp ngăn thư rác.
“Token” API là gì?
Đó giống như mật khẩu bí mật mà ứng dụng dùng để giao tiếp an toàn với Mailtrap. Mỗi môi trường (thử nghiệm và sản phẩm) nên có token riêng.
Chi tiết
Mô tả gốc của tác giả
Guides agents through integrating transactional email sending via Mailtrap's Email API, including sandbox testing, domain verification, and API authentication. Use when implementing email-sending features, debugging delivery issues, or setting up safe dev/staging email testing.
repo: affaan-m/ECC
Độ phổ biến
- Sao GitHub
- 280k
- Vị trí xếp hạng
- #354
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
accessibility
280kGiúp agent của bạn tạo giao diện mà ai cũng dùng được, đảm bảo website và app hoạt động tốt với người khuyết tật như người mù hoặc khó vận động.
agent-architecture-audit
280kGiúp agent của bạn kiểm tra xem mọi thứ có hoạt động đúng không, đồng thời tìm và sửa các lỗi trong hệ thống AI để chúng chạy như mong đợi.
agent-eval
280kGiúp agent của bạn so sánh các công cụ lập trình AI khác nhau, đo xem công cụ nào nhanh hơn, rẻ hơn và đáng tin cậy hơn cho từng tác vụ.
agent-harness-construction
280kGiúp agent của bạn hiểu rõ hơn cách thực hiện tác vụ, tối ưu các công cụ và chỉ dẫn mà agent dùng để tăng khả năng thành công.
Skill tương tự
shopify
260kGiúp agent của bạn đọc và cập nhật dữ liệu cửa hàng Shopify như sản phẩm, tồn kho, đơn hàng và khách hàng qua Shopify GraphQL API.
rest-graphql-debug
260kGiúp agent của bạn tìm lý do một lệnh gọi API REST hoặc GraphQL thất bại, kiểm tra kết nối, đăng nhập, định dạng yêu cầu và phản hồi theo từng lớp.
har-derived-api-client
260kGiúp agent của bạn ghi lại lưu lượng mạng của một website một lần, rồi xây một client API trực tiếp, để không phải nhấp qua trang mỗi lần.