Send transactional email through your own SMTP
Make one HTTPS POST request per message. Your SMTP credentials stay encrypted on MailSetu and are never exposed to your application.
-
1
Connect SMTP
Add your server on SMTP accounts and test the connection.
-
2
Create API key
Generate a bearer key on API keys (shown once).
-
3
Send via REST
Call
POST /v1/emails/sendwith JSON.
Interactive playground
Send a real test email or generate a live cURL snippet from your inputs.
The full API reference below is public. Sign in or create an account to test directly against your SMTP servers.
Authentication
Send your API key as a bearer token. Keys look like ms_live_…. Keep them on your backend and never expose them in browser code.
Authorization: Bearer ms_live_YOUR_API_KEY
Requests without a valid key, or using a revoked or expired key, return 401.
SMTP configuration
Each account stores the fields below. Passwords are encrypted with AES-256-GCM at rest and never displayed again.
| Field | Description |
|---|---|
host | Your provider's SMTP server, for example smtp.gmail.com. |
port | 465 with SSL/TLS, or 587 with STARTTLS. |
security | ssl (implicit TLS) or starttls. |
username & password | Provider SMTP credentials. Gmail and Outlook usually require an app password. |
sender_email | The only address allowed as from. Requests with another address are rejected. |
Send email
Provide html, text, or both. Limits: up to 50 recipients across to, cc, and bcc, and up to 10 MB of attachments per request (120 sends/min per key).
| Field | Type | Required | Notes |
|---|---|---|---|
smtp_id | integer | Yes | ID of one of your SMTP accounts. |
from | string | Yes | Must equal the account's sender_email. |
to | array or string | Yes | At least one address. |
cc, bcc | array | No | Optional recipients. |
subject | string | Yes | Up to 998 characters. |
html, text | string | One of | Your own message body. |
attachments | array | No | Objects with filename, content_type, and base64 content_base64. |
webhook_url | string | No | Optional HTTPS URL to receive automatic email.sent / email.failed events. |
Batch / Bulk send
Send up to 50 personalized emails in a single request using {{ variable }} placeholders.
{
"smtp_id": 1,
"from": "you@yourdomain.com",
"subject": "Hello {{ '{{name}}' }}, order #{{ '{{order_id}}' }}",
"html": "<p>Hi {{ '{{name}}' }}, your order <b>#{{ '{{order_id}}' }}</b> is confirmed.</p>",
"messages": [
{"to": ["alice@example.com"], "variables": {"name": "Alice", "order_id": "1041"}},
{"to": ["bob@example.com"], "variables": {"name": "Bob", "order_id": "1042"}}
]
}
SDK examples
Replace YOUR_API_KEY with your key. Sample uses SMTP account 1 and sender you@yourdomain.com.
curl -X POST https://equivalent-alisa-spideyofficial777-c749c4c7.apps.mistral.run/v1/emails/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"smtp_id": 1,
"from": "you@yourdomain.com",
"to": ["customer@example.com"],
"subject": "Your order has shipped",
"text": "Your order is on its way.",
"html": "<p>Your order is on its way.</p>"
}'
import requests
response = requests.post(
"https://equivalent-alisa-spideyofficial777-c749c4c7.apps.mistral.run/v1/emails/send",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"smtp_id": 1,
"from": "you@yourdomain.com",
"to": ["customer@example.com"],
"subject": "Your order has shipped",
"text": "Your order is on its way.",
},
timeout=30,
)
print(response.status_code, response.json())
const res = await fetch("https://equivalent-alisa-spideyofficial777-c749c4c7.apps.mistral.run/v1/emails/send", {
method: "POST",
headers: {
"Authorization": "Bearer " + process.env.MAILSETU_API_KEY,
"Content-Type": "application/json"
},
body: JSON.stringify({
smtp_id: 1,
from: "you@yourdomain.com",
to: ["customer@example.com"],
subject: "Your order has shipped",
text: "Your order is on its way."
})
});
console.log(res.status, await res.json());
$ch = curl_init("https://equivalent-alisa-spideyofficial777-c749c4c7.apps.mistral.run/v1/emails/send");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer YOUR_API_KEY", "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"smtp_id" => 1,
"from" => "you@yourdomain.com",
"to" => ["customer@example.com"],
"subject" => "Your order has shipped",
"text" => "Your order is on its way.",
]),
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $response;
Responses
A 200 means your SMTP server accepted the message. It does not confirm inbox delivery.
{
"status": "accepted_by_smtp",
"message_id": "<7f3a…@yourdomain.com>",
"note": "The SMTP server accepted the message. Inbox delivery is not guaranteed."
}
{
"status": "failed",
"error": "Authentication failed. Check the SMTP username and password."
}
Error codes
| Code | Meaning | What to do |
|---|---|---|
| 401 | Missing, invalid, revoked, or expired API key. | Check the header format and key status. |
| 403 | The account is blocked or not verified. | Verify your email or contact support. |
| 404 | SMTP account does not exist or belongs to another user. | Check smtp_id. |
| 413 | Attachments exceed the 10 MB limit. | Send smaller files or links. |
| 422 | Validation failed (e.g. from mismatch). | Read the error field and fix the payload. |
| 429 | Too many requests for this key. | Back off and retry shortly. |
| 502 | SMTP server rejected the send or could not be reached. | Test the account on the SMTP page, then retry. |