API-Dokumentation

Mail Send API

API zum einfachen Versenden transaktionaler E-Mails. Unterstützt Einzelversand und Batch-Warteschlangen.

Erforderliche Berechtigung: mail

POST /api/v1/mail/send

Sendet eine einzelne E-Mail sofort. Der Versand erfolgt über den Standard-SMTP-Provider des Benutzers.

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
tostringJaEmpfänger-E-Mail
subjectstringJaE-Mail-Betreff
htmlstringYes*HTML-Inhalt (*html oder text ist erforderlich)
textstringYes*Textinhalt
from_emailstringNeinAbsender-E-Mail (Standard: SMTP-Provider-Einstellung)
from_namestringNeinAbsendername
reply_tostringNeinAntwortadresse
ccarrayNeinCC-E-Mail-Liste
bccarrayNeinBCC-E-Mail-Liste
tagsarrayNeinE-Mail-Tags (zur Klassifizierung)
metadataobjectNeinBenutzerdefinierte Metadaten

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

Fügt mehrere E-Mails zur Warteschlange hinzu. Maximal 100 Stück, Verarbeitung durch 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}

Ruft den Status und die Tracking-Ereignisse einer gesendeten E-Mail ab.

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_ERROR400Pflichtfelder fehlen oder ungültige E-Mail
NO_SMTP_PROVIDER422Kein Standard-SMTP-Provider konfiguriert
SEND_LIMIT_EXCEEDED429Tägliches/stündliches Sendelimit des SMTP-Providers überschritten
SEND_FAILED500E-Mail-Versand fehlgeschlagen

Beispiele

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-Einrichtung erforderlich

Um die Mail Send API zu verwenden, müssen Sie zunächst unter Dashboard > SMTP-Einstellungen einen SMTP-Provider hinzufügen und als Standard festlegen. MailPass-eigener SMTP sowie Amazon SES, SendGrid, Mailgun usw. werden unterstützt.

Wir verwenden Cookies

Wir verwenden Cookies zur Verbesserung Ihres Erlebnisses. Sie können auswählen, welche Cookie-Kategorien Sie erlauben. Erfahren Sie mehr