Mail Send API
API zum einfachen Versenden transaktionaler E-Mails. Unterstützt Einzelversand und Batch-Warteschlangen.
Erforderliche Berechtigung: mail
/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 |
|---|---|---|---|
to | string | Ja | Empfänger-E-Mail |
subject | string | Ja | E-Mail-Betreff |
html | string | Yes* | HTML-Inhalt (*html oder text ist erforderlich) |
text | string | Yes* | Textinhalt |
from_email | string | Nein | Absender-E-Mail (Standard: SMTP-Provider-Einstellung) |
from_name | string | Nein | Absendername |
reply_to | string | Nein | Antwortadresse |
cc | array | Nein | CC-E-Mail-Liste |
bcc | array | Nein | BCC-E-Mail-Liste |
tags | array | Nein | E-Mail-Tags (zur Klassifizierung) |
metadata | object | Nein | Benutzerdefinierte Metadaten |
Response
{
"success": true,
"data": {
"message_id": "<abc123.1706600000@mailpass.im>",
"status": "sent",
"to": "user@example.com",
"from": "support@yourdomain.com"
}
}
/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}
]
}
}
/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_ERROR | 400 | Pflichtfelder fehlen oder ungültige E-Mail |
NO_SMTP_PROVIDER | 422 | Kein Standard-SMTP-Provider konfiguriert |
SEND_LIMIT_EXCEEDED | 429 | Tägliches/stündliches Sendelimit des SMTP-Providers überschritten |
SEND_FAILED | 500 | E-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.