API Docs

Mail Send API

API for easily sending transactional emails. Supports single immediate sending and batch queue sending.

Required permission: mail

POST /api/v1/mail/send

Sends a single email immediately. The email is sent through the user's default 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
tostringYesRecipient email
subjectstringYesEmail subject
htmlstringYes*HTML body (*either html or text is required)
textstringYes*Text body
from_emailstringNoSender email (default: SMTP provider setting)
from_namestringNoSender name
reply_tostringNoReply-to address
ccarrayNoCC email list
bccarrayNoBCC email list
tagsarrayNoEmail tags (for categorization)
metadataobjectNoCustom metadata

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

Adds multiple emails to the queue. Up to 100 emails can be queued and are processed by 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}

Retrieves the status and tracking events of a sent email.

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_ERROR400Missing required fields or invalid email
NO_SMTP_PROVIDER422Default SMTP provider is not configured
SEND_LIMIT_EXCEEDED429SMTP provider daily/hourly sending limit exceeded
SEND_FAILED500Email sending failed

Examples

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 Setup Required

To use the Mail Send API, you must first add an SMTP provider and set it as default in Dashboard > SMTP Settings. MailPass's own SMTP, Amazon SES, SendGrid, Mailgun, and more are supported.

We use cookies

We use cookies to improve your experience. You can choose which cookie categories to allow. Learn more