Communitygithub.com

AgentMail — AIエージェント向けメール基盤

AIエージェントにリアルなメールアドレスとREST APIを提供します。アカウント作成、メール送受信、Webhook管理、カルマ残高確認を可能にします。

AgentMail — AIエージェント向けメール基盤 とは?

AgentMailは、AIエージェントが実際のメールアドレス(`@theagentmail.net`)を持ち、REST APIを通じてメールの送受信、サービスのサインアップ(GitHub、AWS、Slackなど)、確認コードの取得を行うためのメール基盤です。カルマシステムによりスパムを防止し、共有ドメインの評判を高く保ちます。TypeScript SDKも提供されており、アカウント作成、メール送信、受信トレイの確認、添付ファイルのダウンロード、Webhook登録、カルマ残高のチェックなどの操作を簡単に実行できます。エラー処理や一般的なパターン(サービス登録後の確認メール読み取り、メール送信後の返信待ち)の例も豊富に用意されており、AIエージェントの自動化に組み込みやすい設計です。このスキルはClaude Code、Cursor、Codexなどのプラットフォームで利用可能で、エージェントが人間と同じようにメールを使ったコミュニケーションを行う必要がある場合に特に役立ちます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/SamuelChien/mega-skills-collection/tree/HEAD/agentmail

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

AgentMail — AIエージェント向けメール

AgentMailはAIエージェントにリアルなメールアドレス(@theagentmail.net)を提供し、REST APIで操作できます。エージェントはメールの送受信、サービス(GitHub、AWS、Slackなど)へのサインアップ、確認コードの取得が可能です。カルマシステムによりスパムを防止し、共有ドメインの評判を高く保ちます。

ベースURL: https://api.theagentmail.net

使用すべき場合

  • AIエージェントがサインアップ、確認フロー、トランザクションコミュニケーションのために実際の受信箱/送信箱を必要とする場合。
  • AgentMailアカウントのプロビジョニング、メッセージ送信、受信箱内容の読み取り、インバウンドWebhookの登録が必要な場合。
  • カルマ使用量の監視やメールイベントをエージェント自動化に組み込む必要がある場合。

クイックスタート

全てのリクエストにはAuthorization: Bearer am_...ヘッダー(ダッシュボードから取得したAPIキー)が必要です。

メールアカウントを作成する(-10カルマ)

curl -X POST https://api.theagentmail.net/v1/accounts \
  -H "Authorization: Bearer am_..." \
  -H "Content-Type: application/json" \
  -d '{"address": "[email protected]"}'

レスポンス: {"data": {"id": "...", "address": "[email protected]", "displayName": null, "createdAt": 123}}

メールを送信する(-1カルマ)

curl -X POST https://api.theagentmail.net/v1/accounts/{accountId}/messages \
  -H "Authorization: Bearer am_..." \
  -H "Content-Type: application/json" \
  -d '{
    "to": ["[email protected]"],
    "subject": "こんにちは、エージェントからです",
    "text": "プレーンテキスト本文",
    "html": "<p>オプションのHTML本文</p>"
  }'

オプションフィールド: cc, bcc(文字列配列)、inReplyTo, references(スレッド化用の文字列)、attachments({filename, contentType, content}の配列、contentはbase64)。

受信箱を読む

# メッセージ一覧
curl https://api.theagentmail.net/v1/accounts/{accountId}/messages \
  -H "Authorization: Bearer am_..."

# フルメッセージ(本文と添付ファイル付き)を取得
curl https://api.theagentmail.net/v1/accounts/{accountId}/messages/{messageId} \
  -H "Authorization: Bearer am_..."

カルマを確認する

curl https://api.theagentmail.net/v1/karma \
  -H "Authorization: Bearer am_..."

レスポンス: {"data": {"balance": 90, "events": [...]}}

Webhookを登録する(リアルタイムインバウンド)

curl -X POST https://api.theagentmail.net/v1/accounts/{accountId}/webhooks \
  -H "Authorization: Bearer am_..." \
  -H "Content-Type: application/json" \
  -d '{"url": "https://my-agent.example.com/inbox"}'

Webhook配信には2つのセキュリティヘッダーが含まれます:

  • X-AgentMail-Signature -- リクエストボディのHMAC-SHA256 hexダイジェスト。Webhookシークレットで署名されています。
  • X-AgentMail-Timestamp -- 配信が送信された時刻のミリ秒タイムスタンプ。

署名を検証し、5分以上経過したタイムスタンプのリクエストを拒否してリプレイ攻撃を防ぎます:

import { createHmac } from "crypto";

const verifyWebhook = (body: string, signature: string, timestamp: string, secret: string) => {
  if (Date.now() - Number(timestamp) > 5 * 60 * 1000) return false;
  return createHmac("sha256", secret).update(body).digest("hex") === signature;
};

添付ファイルをダウンロードする

curl https://api.theagentmail.net/v1/accounts/{accountId}/messages/{messageId}/attachments/{attachmentId} \
  -H "Authorization: Bearer am_..."

レスポンス: {"data": {"url": "https://signed-download-url..."}}

完全なAPIリファレンス

メソッドパス説明カルマ
POST/v1/accountsメールアカウントを作成-10
GET/v1/accounts全てのアカウントを一覧表示
GET/v1/accounts/:idアカウントの詳細を取得
DELETE/v1/accounts/:idアカウントを削除+10
POST/v1/accounts/:id/messagesメールを送信-1
GET/v1/accounts/:id/messagesメッセージを一覧表示
GET/v1/accounts/:id/messages/:msgIdフルメッセージを取得
GET/v1/accounts/:id/messages/:msgId/attachments/:attId添付ファイルURLを取得
POST/v1/accounts/:id/webhooksWebhookを登録
GET/v1/accounts/:id/webhooksWebhookを一覧表示
DELETE/v1/accounts/:id/webhooks/:whIdWebhookを削除
GET/v1/karma残高とイベントを取得

カルマシステム

全てのアクションにはカルマのコストまたは報酬があります:

イベントカルマ理由
money_paid+100クレジットを購入
email_received+2信頼できるドメインから返信があった
account_deleted+10アドレス削除時にカルマ返金
email_sent-1送信にカルマ消費
account_created-10アドレス作成にカルマ消費

重要なルール:

  • カルマは信頼できるプロバイダー(Gmail、Outlook、Yahoo、iCloud、ProtonMail、Fastmail、Heyなど)からのインバウンドメールに対してのみ付与されます。不明または使い捨てドメインからのメールではカルマは得られません。
  • エージェントが返信するまで、送信者1人につき1回のみカルマが獲得できます。送信者Xが返信なしで5回メールを送ってきても、最初の1回のみカルマが付与されます。Xに返信すると、次のXからのメールで再びカルマが獲得できます。
  • アカウントを削除すると、作成時に消費した10カルマが返金されます。

カルマが0になると、送信とアカウント作成はHTTP 402を返します。カルマを消費する操作の前には必ず残高を確認してください。

TypeScript SDK

import { createClient } from "@agentmail/sdk";

const mail = createClient({ apiKey: "am_..." });

// アカウントを作成
const account = await mail.accounts.create({
  address: "[email protected]",
});

// メールを送信
await mail.messages.send(account.id, {
  to: ["[email protected]"],
  subject: "こんにちは",
  text: "AIエージェントから送信されました。",
});

// 受信箱を読む
const messages = await mail.messages.list(account.id);
const detail = await mail.messages.get(account.id, messages[0].id);

// 添付ファイル
const att = await mail.attachments.getUrl(accountId, messageId, attachmentId);
// att.url は署名付きダウンロードURL

// Webhook
await mail.webhooks.create(account.id, {
  url: "https://my-agent.example.com/inbox",
});

// カルマ
const karma = await mail.karma.getBalance();
console.log(karma.balance);

エラーハンドリング

import { AgentMailError } from "@agentmail/sdk";

try {
  await mail.messages.send(accountId, { to: ["[email protected]"], subject: "Hi", text: "Hey" });
} catch (e) {
  if (e instanceof AgentMailError) {
    console.log(e.status);   // 402, 404, 401 など
    console.log(e.code);     // "INSUFFICIENT_KARMA", "NOT_FOUND" など
    console.log(e.message);
  }
}

一般的なパターン

サービスにサインアップし、確認メールを読む

const account = await mail.accounts.create({
  address: "[email protected]",
});

// このアドレスを使ってサインアップ(ブラウザ自動化、APIなど)

// 確認メールをポーリング
for (let i = 0; i < 30; i++) {
  const messages = await mail.messages.list(account.id);
  const verification = messages.find(m =>
    m.subject.toLowerCase().includes("verify") ||
    m.subject.toLowerCase().includes("confirm")
  );
  if (verification) {
    const detail = await mail.messages.get(account.id, verification.id);
    // detail.bodyText または detail.bodyHtml から確認リンク/コードを解析
    break;
  }
  await new Promise(r => setTimeout(r, 2000));
}

メールを送信し、返信を待つ

const sent = await mail.messages.send(account.id, {
  to: ["[email protected]"],
  subject: "注文#12345に関する質問",
  text: "ステータスを確認していただけますか?",
});

for (let i = 0; i < 60; i++) {
  const messages = await mail.messages.list(account.id);
  const reply = messages.find(m =>
    m.direction === "inbound" && m.timestamp > sent.timestamp
  );
  if (reply) {
    const detail = await mail.messages.get(account.id, reply.id);
    // 返信を処理
    break;
  }
  await new Promise(r => setTimeout(r, 5000));
}

型定義

type Account = { id: string; address: string; displayName: string | null; createdAt: number };
type Message = { id: string; from: string; to: string[]; subject: string; direction: "inbound" | "outbound"; status: string; timestamp: number };
type MessageDetail = Message & { cc: string[] | null; bcc: string[] | null; bodyText: string | null; bodyHtml: string | null; inReplyTo: string | null; references: string | null; attachments: AttachmentMeta[] };
type AttachmentMeta = { id: string; filename: string; contentType: string; size: number };
type KarmaBalance = { balance: number; events: KarmaEvent[] };
type KarmaEvent = { id: string; type: string; amount: number; timestamp: number; metadata?: Record<string, unknown> };

制限事項

  • このスキルは、タスクが上記の範囲に明確に合致する場合にのみ使用してください。
  • 出力を環境固有の検証、テスト、専門家によるレビューの代わりとして扱わないでください。
  • 必要な入力、権限、安全境界、成功基準が不足している場合は、停止して明確化を求めてください。

Individual skills in this repo

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

SamuelChien/mega-skills-collection

Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

SamuelChien/mega-skills-collection

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

SamuelChien/mega-skills-collection

Ingeniero de Sistemas de Andru.ia. Diseña, redacta y despliega nuevas habilidades (skills) dentro del repositorio siguiendo el Estándar de Diamante.

SamuelChien/mega-skills-collection

Estratega de Inteligencia de Dominio de Andru.ia. Analiza el nicho específico de un proyecto para inyectar conocimientos, regulaciones y estándares únicos del sector. Actívalo tras definir el nicho.

SamuelChien/mega-skills-collection

2D game development principles. Sprites, tilemaps, physics, camera.

SamuelChien/mega-skills-collection

3D game development principles. Rendering, shaders, physics, cameras.

SamuelChien/mega-skills-collection

Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences.

SamuelChien/mega-skills-collection

Accessibility audit skill for scanning, fixing, and verifying WCAG 2.2 Level A and AA compliance across React, Next.js, Vue, Angular, Svelte, and plain HTML codebases. Use when auditing accessibility, fixing a11y violations, checking color contrast, generating compliance reports, or integrating accessibility checks into CI/CD pipelines.

SamuelChien/mega-skills-collection

Ab Test Analyzer - Auto-activating skill for Data Analytics. Triggers on: ab test analyzer, ab test analyzer Part of the Data Analytics skill category.

SamuelChien/mega-skills-collection

A B Test Config Creator - Auto-activating skill for ML Deployment. Triggers on: a b test config creator, a b test config creator Part of the ML Deployment skill category.

SamuelChien/mega-skills-collection

When the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "conversion experiment," "statistical significance," or "test this." For tracking implementation, see analytics-tracking.

SamuelChien/mega-skills-collection

Acceptance Criteria Creator - Auto-activating skill for Enterprise Workflows. Triggers on: acceptance criteria creator, acceptance criteria creator Part of the Enterprise Workflows skill category.

SamuelChien/mega-skills-collection

Use when a coding task should be driven end-to-end from issue intake through implementation, review, deployment, and acceptance verification with minimal human re-intervention.

SamuelChien/mega-skills-collection

Accessibility Audit Runner - Auto-activating skill for Frontend Development. Triggers on: accessibility audit runner, accessibility audit runner Part of the Frontend Development skill category.

SamuelChien/mega-skills-collection

You are an accessibility expert specializing in WCAG compliance, inclusive design, and assistive technology compatibility. Conduct audits, identify barriers, and provide remediation guidance.

SamuelChien/mega-skills-collection

Web accessibility patterns for WCAG 2.2 compliance including ARIA, keyboard navigation, screen readers, and testing

SamuelChien/mega-skills-collection

Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed, or change policy for the Discord channel.

SamuelChien/mega-skills-collection

Create unified specification packages across Business, Development, and Design teams. Staged elaboration (L0 Vision → L1 Requirements → L2 Team Detail → L3 Acceptance Criteria) to build shared understanding. Does not write code.

SamuelChien/mega-skills-collection

Research a company or person and get actionable sales intel. Works standalone with web search, supercharged when you connect enrichment tools or your CRM. Trigger with "research [company]", "look up [person]", "intel on [prospect]", "who is [name] at [company]", or "tell me about [company]".

SamuelChien/mega-skills-collection

Validate messaging consistency across website, GitHub repos, and local documentation generating read-only discrepancy reports. Use when checking content alignment or finding mixed messaging. Trigger with phrases like "check consistency", "validate documentation", or "audit messaging".

関連スキル