本文へスキップ
Skillpedia
APIとサーバー(バックエンド)280k · #354

mailtrap-email-integration

できること

このツールは、Mailtrapサービスを使って、会員登録の確認メールやパスワード再設定メールなどを、アプリケーションから自動的に送信できるようにします。テストで送ったメールが実際のユーザーに届かないようにし、お客様に送るメールが正しく動くかも確認できます。

使う場面

  • ✓会員登録の確認メールなど、自動でメールを送信したいとき。
  • ✓誰にも迷惑をかけずに、テストメールが正しく届くかを確認したいとき。
  • ✓プロジェクトで初めてメール送信を設定するとき。

スキルのリンク

https://github.com/affaan-m/ECC/blob/main/skills/mailtrap-email-integration/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/affaan-m/ECC/blob/main/skills/mailtrap-email-integration/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Mailtrap Sandboxを使ってテストメールを送信するには、どうすればよいですか?”

毎週5つの新しいスキル。1分で読めます。

仕組み

このツールはMailtrapのAPIを使ってメールを送信します。テストの場合は、メールを受け取って記録する「サンドボックス」を使います。実際のメールを送る場合は、送信元ドメインの所有を確認したあとに、別のエンドポイントを使います。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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

よくある質問

Mailtrapの「サンドボックス」とは何ですか?

送信されたすべてのメールを、実際の受信者には届けずに受け取るテスト用の環境です。実際にメールを送らずにテストしたいときに最適です。

なぜドメインの確認が必要なのですか?

お客様に実際のメールを送るには、Mailtrapがそのメールの送信元ドメインがあなたのものであることを確認する必要があります。これは迷惑メールの防止にも役立ちます。

APIの「トークン」とは何ですか?

アプリケーションがMailtrapと安全に通信するために使う、秘密のパスワードのようなものです。テスト環境と本番環境には、それぞれ別のトークンを用意すべきです。

詳細

作者による元の説明

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

人気

GitHubのスター
280k
ランキング
#354
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル