Skip to content
Writing
MailgunMigrationEmail APIDevOps

Migrating from Mailgun to SadaSend in 10 Minutes (Step-by-Step Guide)

Tired of complex Mailgun domain setups, confusing invoice add-ons, and legacy SDKs? Here is the step-by-step guide to migrating to SadaSend in under 10 minutes.

Tayyab MughalFounder & AI Chief2 min read

Why developers are moving away from Mailgun

Mailgun pioneered developer email in 2010, but over the years its pricing has shifted toward complex volume tiers, support response times have degraded, and its SDKs remain heavyweight wrappers over legacy multipart form data.

SadaSend provides a pure JSON REST API, instant domain DNS auto-verification, scoped API keys for AI agents, and predictable transparent pricing.

API Code Migration: Mailgun.js vs SadaSend

ConceptLegacy Mailgun (mailgun.js)Modern SadaSend (Native Fetch)
SDK Requirementmailgun.js + form-data + buffer0 dependencies (Web-standard fetch)
Payload FormatMultipart form-dataStandard application/json
AuthenticationBasic Auth (api:key-...) or BearerStandard Bearer token Authorization header
Domain MappingRequires domain in URL pathDomain inferred automatically from "from" header

Code Migration Comparison (TypeScript)

Replace 15 lines of Mailgun client initialization with a clean 6-line native fetch call.

TYPESCRIPT
// BEFORE: Legacy Mailgun SDK
// import Mailgun from 'mailgun.js';
// import formData from 'form-data';
// const mg = new Mailgun(formData).client({ username: 'api', key: process.env.MAILGUN_API_KEY! });
// await mg.messages.create('mg.yourdomain.com', { from: 'hello@yourdomain.com', to: ['user@acme.com'], subject: 'Hi', text: 'Hello' });

// AFTER: Modern SadaSend Native Fetch
const res = await fetch('https://api.sadasend.com/v1/emails', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.SADASEND_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    to: 'user@acme.com',
    subject: 'Welcome to SadaSend',
    text: 'Your migration is complete!',
  }),
});
const data = await res.json();

Zero-Downtime DNS Migration Steps

  • 1. Add your sending domain in the SadaSend dashboard (/app/domains/new).
  • 2. Copy the 3 DKIM CNAME records and SPF TXT record into your DNS provider (Cloudflare, Route53, Namecheap).
  • 3. Once verified in SadaSend, update your environment variables (SADASEND_API_KEY) in production.
  • 4. Keep your Mailgun account active for 48 hours to handle any in-flight retries before cancelling.
Early Access

Building AI agents that send email?

Join the SadaSend early access waitlist to get scoped API keys, recipient allowlists, and Model Context Protocol (MCP) servers upon launch.

Rolling out in developer batches·No credit card needed