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

SendGrid vs Mailgun

SendGrid vs Mailgun for developers: a short verdict, side-by-side message field support, and one TypeScript send call that works with either API.

Short answer: Pick SendGrid if marketing campaigns, subusers and IP management should live in the same account as your transactional email. Pick Mailgun for inbound routing and parsing, EU region hosting and developer-friendly logs. Both support every message field Email SDK models, including metadata and scheduled sending, so its field checks pass a SendGrid-to-Mailgun fallback for any message, and Mailgun-to-SendGrid for messages without repeated header names. Falling back when delivery is unknown also needs onUnknownDelivery: “continue”, which can send a duplicate.

SendGrid and Mailgun are the two heavyweight generalists of email infrastructure, and on the unified message shape they are actually identical: both support every field the SDK models — CC, BCC, reply-to, custom headers, attachments, tags, metadata, and scheduled sending — so either can serve as the other’s fallback. The one edge is repeated header names, which Mailgun accepts and SendGrid rejects. The decision therefore comes down to the platforms around the API. SendGrid brings Twilio-scale infrastructure, marketing campaigns in the same account, subusers, and granular IP management. Mailgun counters with stronger inbound mail processing, straightforward EU data residency, message retention options, and a reputation for developer-friendly logs and webhooks. Pricing at low volume is comparable; at high volume both reward negotiation, so benchmark real traffic — ideally through the SDK, where swapping the adapter is one line — before committing either way.

Message field support

Field support as encoded in Email SDK’s own adapter capability matrix, the same data the SDK uses to reject sends that would silently drop fields.

Message field SendGrid Mailgun
CC recipients ✓ ✓
BCC recipients ✓ ✓
Reply-To address ✓ ✓
Custom headers ✓ ✓
Attachments ✓ ✓
Tags ✓ ✓
Metadata ✓ ✓
Scheduled sending (sendAt) ✓ ✓

Fallback compatibility

SendGrid and Mailgun support identical message fields, so Email SDK can fail over between them in either direction without losing data.

Same code, either provider

With Email SDK the send call is identical for both providers. Only the adapter import changes:

Or run both, with automatic fallback:

FAQ

Should I use SendGrid or Mailgun?

Pick SendGrid if marketing campaigns, subusers and IP management should live in the same account as your transactional email. Pick Mailgun for inbound routing and parsing, EU region hosting and developer-friendly logs. Both support every message field Email SDK models, including metadata and scheduled sending, so its field checks pass a SendGrid-to-Mailgun fallback for any message, and Mailgun-to-SendGrid for messages without repeated header names. Falling back when delivery is unknown also needs onUnknownDelivery: “continue”, which can send a duplicate.

Can I switch from SendGrid to Mailgun without rewriting my email code?

Yes. With Email SDK both providers share one typed send() call and one message shape, so switching from SendGrid to Mailgun is a one-line adapter change plus an API key. The SDK fails fast if a message uses a field Mailgun does not support, so nothing is silently dropped.

Which message fields does SendGrid support that Mailgun doesn’t?

Mailgun supports every message field that SendGrid supports, so nothing is lost moving a message from SendGrid to Mailgun.

Can I use Mailgun as a fallback for SendGrid?

Partially. Email SDK checks field support before every send: a fallback is rejected from Mailgun to SendGrid for messages using repeated header names. Messages that avoid those pass the field checks. A failed send still falls back only when the SDK knows the first provider didn’t send it, unless you set onUnknownDelivery: “continue”. Adapter limits also apply. SendGrid: Native personalized delivery caps one request at 1,000 recipients. SendGrid: Tag names are discarded; tag values are sent as categories. Mailgun: Native personalized delivery caps one request at 1,000 recipients. Mailgun: Tag names are discarded; tag values are sent as o:tag values.

Adapter docs

Setup guides: SendGrid adapter and Mailgun adapter. Sending from your own domain? Verify SPF, DKIM, and DMARC with the free email DNS checker.

Calling the API directly? Read the SendGrid API guide for Node.js and TypeScript.

Moving off SendGrid? Read the SendGrid alternatives guide.

Estimating the bill? Read the SendGrid pricing guide.

Calling the API directly? Read the Mailgun API guide for Node.js and TypeScript.

Moving off Mailgun? Read the Mailgun alternatives guide.

Estimating the bill? Read the Mailgun pricing guide.

Last updated on