← All migration guides

Migration guide / Transactional email

Migrate from Mailgun to SMTPfast.

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.

Move to SMTPfast if

  • You want one JSON API and one suppression list for all your sending domains.
  • You want up to 50 tags per email (Mailgun: 3) and an Idempotency-Key on sends.
  • You want marketing opt-outs that let receipts and resets through.

Stay on Mailgun if

  • You send batches of up to 1,000 recipients with recipient-variables in one call.
  • Your templates use Handlebars logic, or you need template versions.
  • You use inbound routes with complex filters, dedicated IPs or the EU region.

The code change.

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"
  }'

What maps to what.

Sending
MailgunSMTPfast
POST /v3/{domain}/messages, Basic auth api:KEYPOST /v1/emails, Authorization: Bearer KEYThe domain comes from the from address, which must be on a verified domain.
from, to, cc, bcc, subject, html, textfrom, to, cc, bcc, subject, html, text
h:Reply-Toreply_to
h:X-My-Headerheaders: { "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-vartags [{ 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-openstrack_clicks, track_opens (true or false)
o:testmodeNo 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.
SMTP
MailgunSMTPfast
Host smtp.mailgun.orgHost 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 loginUsername smtpfast
Password SMTP passwordAn SMTPfast API key with the email:send scope
Webhooks
MailgunSMTPfast
acceptedemail.sent
deliveredemail.delivered
temporary_failemail.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_failemail.bounced or email.failed
complainedemail.complained
opened, clickedemail.opened, email.clicked
unsubscribedemail.unsubscribed
signature { token, timestamp, signature } in the bodyX-SMTPfast-Signature header over the raw body
Templates, suppressions and lists
MailgunSMTPfast
template, t:variables (Handlebars)template: { id, variables } with {{{VARIABLE}}}No #if, #each or versions. Values are strings or numbers.
/v3/{domain}/bounces, /complaintsSuppressions, scope allOne list for the team, not per domain.
/v3/{domain}/unsubscribesSuppressions, scope marketing
Mailing listsContacts and segments
Routes (inbound)Inbound on a sending domain, email.received webhookPaid plans. Messages are stored for 30 days.

Step by step.

  1. 1

    Add and verify your sending domain

    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.

  2. 2

    Create an API key

    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).

  3. 3

    Rewrite the send call

    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.

  4. 4

    Export and import suppressions

    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.

  5. 5

    Move templates and lists

    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.

  6. 6

    Point your webhooks at the new events

    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);
    }
  7. 7

    Send a test and move traffic in stages

    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.

What SMTPfast does not have

Check these before you move. If one is a blocker, stay where you are.

  • Batch is 100 emails per request, with no recipient-variables. Mailgun takes up to 1,000 recipients.
  • Templates have plain variables: no Handlebars logic and no versions.
  • No inbound routes with filter expressions. Inbound mail arrives by webhook and API.
  • No EU region choice and no dedicated IPs.
  • No implicit TLS SMTP port (465). Webhooks and inbound need a paid plan.

Frequently asked questions.

Do I need one API key per domain like Mailgun's SMTP logins?

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.

How do my Mailgun tags and variables show up?

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.

Try it on the free plan

Verify a domain, send a test and check it in Logs before you move any traffic. Webhooks and inbound mail need a paid plan.