Communitygithub.com

mailtrap-email-integration

에이전트가 Mailtrap을 통해 트랜잭션 이메일 전송을 통합하도록 안내합니다.

mailtrap-email-integration란 무엇인가요?

이 스킬은 애플리케이션에 트랜잭션 이메일 전송 기능을 추가할 때 Mailtrap의 Email API와 Sandbox를 활용하는 방법을 안내합니다. 인증, 환경 분리, 그리고 일반적인 전송 실패 문제를 다룹니다. 개발 환경에서는 Sandbox API를 사용하여 실제 수신자에게 이메일이 발송되지 않도록 하고, 프로덕션 환경에서는 별도의 검증된 도메인 엔드포인트를 사용합니다. 이 스킬은 Claude Code, Cursor, Codex 등 주요 AI 에이전트 플랫폼에서 사용할 수 있으며, API 키와 환경 변수 관리를 포함한 보안 모범 사례도 함께 제시합니다. 코드 예제를 통해 발송 실패 시 재시도 및 오류 처리 방법을 학습할 수 있어, 실제 프로덕션 환경에서 안정적인 이메일 전송을 구현하는 데 유용합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/mailtrap-email-integration

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Mailtrap Email Integration

애플리케이션에 트랜잭션 이메일 전송을 추가하기 위한 패턴입니다. Mailtrap의 Email API와 Sandbox를 사용하며, 인증, 환경 분리, 그리고 일반적인 전송 실패 문제를 다룹니다.

활성화 시점

  • "이메일 보내기" 기능 구현 (회원가입 확인, 비밀번호 재설정, 알림, 영수증)
  • 개발/스테이징 환경에서 이메일이 도착하지 않는 문제 디버깅
  • 프로젝트의 첫 이메일 전송 통합 설정
  • 샌드박스 분리 없이 이메일 API를 직접 호출하는 코드 검토

핵심 개념

Sandbox와 Production 분리. Mailtrap은 Sandbox API를 제공하여 이메일을 캡처하고 실제로 전송하지 않습니다. 개발/스테이징 환경에서 사용하여 테스트 이메일이 실제 받은 편지함에 도달하지 않도록 합니다. 프로덕션 전송은 별도의 검증된 도메인 엔드포인트를 사용합니다. 개발 환경을 프로덕션 전송 엔드포인트에 연결하지 마세요.

인증. 요청은 Authorization 헤더에 Bearer 토큰을 사용합니다. 토큰은 프로젝트별로 범위가 지정되며, 샌드박스와 프로덕션은 일반적으로 다른 토큰을 사용합니다.

도메인 검증. 프로덕션 전송을 위해서는 DNS 레코드(SPF, DKIM, DMARC)를 통해 발송 도메인을 검증해야 Mailtrap이 실제 수신자에게 전달합니다. 이 단계를 생략하면 이메일이 자동으로 실패하거나 스팸 폴더로 분류됩니다.

코드 예제

// Mailtrap Email API를 통한 프로덕션 전송
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: "[email protected]", name: "Your App" },
      to: [{ email: to }],
      subject,
      html,
    }),
  });

  if (!response.ok) {
    throw new Error(`Email send failed: ${response.status}`);
  }
  return response.json();
}
// 동일한 호출, 비-프로덕션 환경에서는 Sandbox로 라우팅
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}`;

안티 패턴

안티 패턴문제점대안
개발/테스트에서 프로덕션 전송 엔드포인트 사용실제 테스트 이메일이 실제 받은 편지함에 도달하여 스팸 신고 위험 및 테스트 데이터 유출 가능비-프로덕션 환경을 Sandbox 엔드포인트로 라우팅
API 토큰을 소스 코드에 하드코딩버전 관리에 커밋될 경우 자격 증명 유출 위험환경 변수 / 시크릿 관리자에서 토큰 로드
도메인 검증 완료 전에 전송이메일이 자동으로 실패하거나 스팸으로 분류됨프로덕션 전송 활성화 전에 SPF/DKIM/DMARC 레코드 검증
전송 실패 시 재시도/오류 처리 없음알림 전송 실패가 사용자에게 전달되지 않음 (예: 비밀번호 재설정 이메일을 받지 못함)응답 상태 확인, 실패 기록, 실행 가능한 오류 표시

모범 사례

  • 샌드박스와 프로덕션 토큰을 별도의 환경 변수에 보관하고, 절대 하나의 토큰을 여러 환경에서 공유하지 마세요.
  • 프로덕션 출시 전에 발송 도메인 DNS 레코드를 검증하세요.
  • 전송 실패를 충분한 컨텍스트(수신자, 템플릿, 타임스탬프, 응답 코드)와 함께 기록하세요.
  • 이메일 전송을 실패 가능한 네트워크 호출로 취급하고, try/catch로 감싸고 절대 성공을 가정하지 마세요.

관련 스킬

api-and-interface-design, security-and-hardening, ci-cd-and-automation

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

관련 스킬