Skip to content
Email SDK
Esc
↑↓navigate↵open⌘Jpreview
On this page

Mailgun

Send through the Mailgun Messages API with domain-scoped multipart sends, h:/v:/o: field mapping, and full field support.

Capabilities

Repeated headers Idempotency Scheduling Personalized
Yes none Yes native

These values come from the adapter’s exported capabilities declaration. The field support matrix covers normalized message fields.

The Mailgun adapter calls the Mailgun Messages API with plain fetch. It is the one adapter that posts multipart form data instead of JSON, using Mailgun’s prefixed field names: h: for headers, v: for metadata variables, o: for sending options. Every send is scoped to the domain you configure.

New to the Mailgun API itself? The Mailgun API guide for Node.js and TypeScript walks through raw requests, US and EU regions, errors, rate limits, and webhooks before it gets to this adapter.

Moving off Mailgun instead? Mailgun alternatives for developers compares prices and log retention, then switches providers with Mailgun kept as the fallback.

Estimating the bill? Mailgun pricing lists every plan, overage rate and log retention limit, checked November 2026.

Mailgun logo
Mailgun@opencoredev/email-sdk/mailgun
Provider docs

Configure

Grab an API key from the Mailgun dashboard and note the sending domain it belongs to. Both are required.

PropType
apiKeystring

Mailgun API key, sent as Basic auth (api:key).

Typestring
domainstring

Sending domain. Requests go to /v3/{domain}/messages.

Typestring
baseUrl?string

Override the API origin, e.g. for the EU region.

Typestring
Default"https://api.mailgun.net"
fetch?typeof fetch

Custom fetch implementation for tests or special runtimes.

Typetypeof fetch

Send

Mailgun maps every common field: cc, bcc, replyTo, headers (as h:Name), attachments (multipart attachment/inline parts by disposition), tags (values as o:tag), and metadata (as v:key variables, surfaced later in webhooks and logs). sendAt becomes a native scheduled send via o:deliverytime (RFC 2822); Mailgun accepts up to 3 days out on most plans, 7 with extended storage.

The response id is Mailgun’s queued message id from the response body. Match it against delivery events in webhooks or the Mailgun logs.

Personalized sends

Mailgun implements native sendPersonalized, so all recipients and variables travel in one request through Mailgun’s recipient-variables field.

Verify from the CLI

Credentials also work as flags: --api-key, --domain, and --base-url (or MAILGUN_BASE_URL) override the environment. Drop --dry-run for one real send to prove the domain’s DNS records and the account are actually ready.

Compare Mailgun with other providers

Side-by-side message-field support from the SDK capability matrix, with working code for both adapters:

Frequently asked questions

Does Email SDK support Mailgun?

Yes. Email SDK ships a Mailgun adapter imported from @opencoredev/email-sdk/mailgun. You keep your Mailgun account and credentials; the SDK adds message validation, typed errors, and no-network test adapters around the same send() call used for every other provider.

Which message fields does the Mailgun adapter support?

Mailgun supports every normalized message field: CC recipients, BCC recipients, Reply-To address, Custom headers, Attachments, Tags, Metadata, and Scheduled sending (sendAt).

Can Mailgun schedule email for later with Email SDK?

Yes. Set sendAt on the message and the Mailgun adapter passes the scheduled time to the provider.

Does the Mailgun adapter support idempotent sends?

No. Mailgun has no provider-side idempotency, so a retried send can be delivered twice. A send with idempotencyKey on a route that includes Mailgun fails with EmailValidationError unless you pass idempotency: “best-effort”. Deduplicate in your own queue before retrying.

Last updated on