Migration guide / Transactional email
Swap form fields and Basic auth for a JSON body and a Bearer key, then map events and per-domain suppressions.
Mailgun sends from POST /v3/{domain}/messages with multipart form fields and HTTP Basic auth, and keeps suppressions per domain. SMTPfast takes a JSON body with a Bearer API key, one endpoint for every domain, and one suppression list per team. The o:, h: and v: prefixes each have a plain JSON field.
Mailgun details checked against its own docs on 2026-12-02. Still deciding? SMTPfast vs Mailgun.
Before: Mailgun
curl -s --user "api:$MAILGUN_API_KEY" \
https://api.mailgun.net/v3/acme.com/messages \
-F from="Acme <[email protected]>" \
-F [email protected] \
-F subject="Your receipt" \
-F html="<p>Thanks for your order.</p>" \
-F o:tag=receipt \
-F v:order_id=1041 \
-F h:[email protected]After: SMTPfast
curl -X POST https://smtpfa.st/api/v1/emails \
-H "Authorization: Bearer $SMTPFAST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <[email protected]>",
"to": [
"[email protected]"
],
"subject": "Your receipt",
"html": "<p>Thanks for your order.</p>",
"reply_to": "[email protected]",
"tags": [
{
"name": "type",
"value": "receipt"
},
{
"name": "order_id",
"value": "1041"
}
],
"category": "transactional"
}'import { SMTPfast } from "@smtpfast/sdk";
const smtpfast = new SMTPfast(); // reads SMTPFAST_API_KEY
const { id } = await smtpfast.emails.send({
from: "Acme <[email protected]>",
to: ["[email protected]"],
subject: "Your receipt",
html: "<p>Thanks for your order.</p>",
reply_to: "[email protected]",
tags: [
{
name: "type",
value: "receipt",
},
{
name: "order_id",
value: "1041",
},
],
category: "transactional",
});| Mailgun | SMTPfast |
|---|---|
| POST /v3/{domain}/messages, Basic auth api:KEY | POST /v1/emails, Authorization: Bearer KEYThe domain comes from the from address, which must be on a verified domain. |
| from, to, cc, bcc, subject, html, text | from, to, cc, bcc, subject, html, text |
| h:Reply-To | reply_to |
| h:X-My-Header | headers: { "X-My-Header": "..." } |
| attachment, inline (files) | attachments [{ filename, content, content_type, content_id }]Base64 in JSON. A content_id makes it inline. |
| o:tag (up to 3), v:my-var | tags [{ name, value }] (up to 50) |
| o:deliverytime (3 or 7 days ahead) | scheduled_at (ISO 8601, up to 30 days) |
| o:tracking-clicks, o:tracking-opens | track_clicks, track_opens (true or false) |
| o:testmode | No equivalentEvery accepted email is sent. Test with addresses you own. |
| recipient-variables (up to 1,000) | POST /v1/emails/batch (100 emails)Render each recipient's values into its own item. |
| Mailgun | SMTPfast |
|---|---|
| Host smtp.mailgun.org | Host smtp.smtpfa.st |
| Ports 25, 587, 2525 (STARTTLS), 465 (TLS) | Ports 587 and 2525, STARTTLSThere is no implicit TLS port (465). Use 587, or 2525 where 587 is blocked. |
| Username per-domain SMTP login | Username smtpfast |
| Password SMTP password | An SMTPfast API key with the email:send scope |
| Mailgun | SMTPfast |
|---|---|
| accepted | email.sent |
| delivered | email.delivered |
| temporary_fail | email.delivery_delayedNot the same event: it fires when SMTPfast retries handing the email to its provider, not for delays at the receiving server, which SMTPfast does not report. |
| permanent_fail | email.bounced or email.failed |
| complained | email.complained |
| opened, clicked | email.opened, email.clicked |
| unsubscribed | email.unsubscribed |
| signature { token, timestamp, signature } in the body | X-SMTPfast-Signature header over the raw body |
| Mailgun | SMTPfast |
|---|---|
| template, t:variables (Handlebars) | template: { id, variables } with {{{VARIABLE}}}No #if, #each or versions. Values are strings or numbers. |
| /v3/{domain}/bounces, /complaints | Suppressions, scope allOne list for the team, not per domain. |
| /v3/{domain}/unsubscribes | Suppressions, scope marketing |
| Mailing lists | Contacts and segments |
| Routes (inbound) | Inbound on a sending domain, email.received webhookPaid plans. Messages are stored for 30 days. |
Add the domain in the dashboard (or with POST /v1/domains) and publish the records it shows: three DKIM CNAMEs, an MX and an SPF TXT record for the bounce subdomain (MAIL FROM), and include:amazonses.com in the SPF record of the domain. A domain has one SPF record, so add the include to the one you have. The DKIM and bounce records have their own names, so they sit next to your current provider's records and both can send while you switch. Keep your DMARC record if you have one. On Cloudflare DNS, SMTPfast can add the records for you.
Create a key with the email:send scope for the app that sends. Give webhook and contact jobs their own keys with only the scopes they need (webhook:write, contact:write).
Send JSON instead of form fields. h:Reply-To becomes reply_to, other h: headers go in headers, o:tag and v: variables become tags, o:deliverytime becomes scheduled_at in ISO 8601. Add category: "transactional" to mail people need. Over SMTP, X-Mailgun-* headers have no effect: use X-SMTPfast-Category and X-SMTPfast-Track-Clicks or -Opens instead.
For each sending domain, page through GET /v3/{domain}/bounces and /complaints and add the addresses with POST /v1/suppressions/batch/add, 100 per call. Add /unsubscribes with POST /v1/suppressions and scope marketing. Addresses from every domain go into one list.
Recreate the templates you still use, with {{name}} written as {{{NAME}}}. Variable values are escaped, so emails that need loops or conditions are better rendered in your code and sent as html. Page through GET /v3/lists/{list}/members/pages and post members to /v1/contacts as { contacts: [...] }, 500 per call, with unsubscribed kept.
Create a webhook for the email.* events that replace your Mailgun events and check the X-SMTPfast-Signature header: a hex HMAC-SHA256 of the raw body with the webhook's signing secret. Every event body is { type, timestamp, data }. Failed deliveries are retried 4 more times over about 36 minutes, and you can replay any of them from the delivery log.
import crypto from "node:crypto";
// rawBody: the request body exactly as received, before JSON.parse
function isFromSmtpfast(rawBody: string, signature: string, secret: string) {
const expected = crypto.createHmac("sha256", secret).update(rawBody).digest();
const given = Buffer.from(signature, "hex");
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
}Send to an address you own and check the email in Logs, then in the received message headers (DKIM and SPF pass, aligned with your From domain). Move one kind of mail first, such as password resets, and watch bounces and complaints for a few days before you move the rest. A new account has warm-up limits, so a large list should not move in one day.
Check these before you move. If one is a blocker, stay where you are.
No. One API key can send from any verified domain on the team. You can still create one key per app to keep them apart.
Both become tags: an o:tag becomes a tag with a name you choose, and v:order_id=1041 becomes { name: "order_id", value: "1041" }. They are stored with the email: GET /v1/emails/:id returns them and Logs can filter by them. Webhook events carry the email_id, not the tags.
Verify a domain, send a test and check it in Logs before you move any traffic. Webhooks and inbound mail need a paid plan.