APIドキュメントへ

Mail Send API

トランザクションメールを簡単に送信するAPIです。単件即時送信およびバッチキュー送信をサポートしています。

必要な権限: mail

POST /api/v1/mail/send

単件メールを即時送信します。ユーザーのデフォルトSMTP providerを通じて送信されます。

Request Body

{
  "to": "user@example.com",
  "subject": "Order Confirmation",
  "html": "<h1>Your order has been confirmed</h1>",
  "text": "Your order has been confirmed",
  "from_email": "support@yourdomain.com",
  "from_name": "Your App",
  "reply_to": "reply@yourdomain.com",
  "cc": ["cc@example.com"],
  "bcc": ["bcc@example.com"],
  "tags": ["order", "confirmation"],
  "metadata": {"order_id": "12345"}
}

Parameters

Field Type Required Description
tostringYes受信者メール
subjectstringYesメール件名
htmlstringYes*HTML本文(*htmlまたはtextのいずれか必須)
textstringYes*テキスト本文
from_emailstringNo送信者メール(デフォルト: SMTP provider設定)
from_namestringNo送信者名
reply_tostringNo返信先アドレス
ccarrayNoCCメールリスト
bccarrayNoBCCメールリスト
tagsarrayNoメールタグ(分類用)
metadataobjectNoユーザー定義メタデータ

Response

{
  "success": true,
  "data": {
    "message_id": "<abc123.1706600000@mailpass.im>",
    "status": "sent",
    "to": "user@example.com",
    "from": "support@yourdomain.com"
  }
}
POST /api/v1/mail/send-batch

複数メールをキューに追加します。最大100件まで可能で、Cronによって処理されます。

Request Body

{
  "messages": [
    {"to": "a@example.com", "subject": "Hello A", "html": "<p>Hi A</p>"},
    {"to": "b@example.com", "subject": "Hello B", "html": "<p>Hi B</p>"}
  ],
  "from_email": "support@yourdomain.com",
  "from_name": "Your App"
}

Response

{
  "success": true,
  "data": {
    "total": 2,
    "queued": 2,
    "failed": 0,
    "messages": [
      {"to": "a@example.com", "status": "queued", "queue_id": 101},
      {"to": "b@example.com", "status": "queued", "queue_id": 102}
    ]
  }
}
GET /api/v1/mail/status/{message_id}

送信済みメールのステータスおよび追跡イベントを照会します。

Response

{
  "success": true,
  "data": {
    "message": {
      "message_id": "<abc123@mailpass.im>",
      "from_email": "support@yourdomain.com",
      "to_email": "user@example.com",
      "subject": "Order Confirmation",
      "status": "sent",
      "error_message": null,
      "sent_at": "2026-01-30T12:00:00",
      "created_at": "2026-01-30T12:00:00"
    },
    "events": [
      {
        "event_type": "open",
        "ip_address": "192.168.1.1",
        "user_agent": "Mozilla/5.0...",
        "created_at": "2026-01-30T12:05:00"
      }
    ]
  }
}

Error Codes

Code HTTP Description
VALIDATION_ERROR400必須フィールドの欠落または無効なメール
NO_SMTP_PROVIDER422デフォルトSMTP providerが設定されていません
SEND_LIMIT_EXCEEDED429SMTP providerの日次/時間別送信上限を超過
SEND_FAILED500メール送信失敗

使用例

cURL

# Single send
curl -X POST https://dev.mailpass.im/api/v1/mail/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "subject": "Hello",
    "html": "<p>Hello World</p>"
  }'

# Batch send
curl -X POST https://dev.mailpass.im/api/v1/mail/send-batch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"to": "a@example.com", "subject": "Hi A", "html": "<p>Hello A</p>"},
      {"to": "b@example.com", "subject": "Hi B", "html": "<p>Hello B</p>"}
    ],
    "from_email": "support@yourdomain.com"
  }'

# Check status
curl https://dev.mailpass.im/api/v1/mail/status/MESSAGE_ID \
  -H "Authorization: Bearer YOUR_API_KEY"

JavaScript (fetch)

// Single send
const response = await fetch('https://dev.mailpass.im/api/v1/mail/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    to: 'user@example.com',
    subject: 'Hello',
    html: '<p>Hello World</p>'
  })
});
const data = await response.json();
console.log(data.data.message_id);

PHP SDK

$client = new MailPass\Client('mp_live_YOUR_KEY');

// Single send
$result = $client->mail->send([
    'to' => 'user@example.com',
    'subject' => 'Hello',
    'html' => '<p>Hello World</p>',
]);
echo $result['data']['message_id'];

SMTP Provider設定が必要

Mail Send APIを使用するには、まずダッシュボード > SMTP設定でSMTP providerを追加し、デフォルトに設定する必要があります。MailPass自体のSMTPまたはAmazon SES、SendGrid、Mailgunなどをサポートしています。

クッキーを使用しています

ユーザー体験を向上させるためにクッキーを使用しています。許可するクッキーカテゴリを選択できます。 詳細を知る