Migrate from Mailgun

The camelmailer-migrate tool reads your Mailgun account over its API and recreates it in CamelMailer: sending domains, routes, suppressions, templates, and past messages with --history. Two things move differently on purpose. Mailgun keeps your sending API key and your DKIM private key to itself, so the tool creates a fresh CamelMailer credential and a fresh per-domain DKIM key for you to publish.

What maps to what

Mailgun spreads sending, authentication, and events across domains and account-level routes. CamelMailer folds them into one server with its own domains, suppressions, templates, routes, and webhooks.

MailgunCamelMailer
Private API key (HTTP basic api:key)A new server API credential in the X-Server-API-Key header. Mailgun does not return existing keys over its API, so the tool mints a fresh one for you to set in your app. See Credentials.
Sending domain with DKIM and SPFSending domain with a fresh per-domain DKIM key, an SPF include, and a verification TXT record. The DKIM private key stays inside Mailgun, so CamelMailer generates its own.
Routes (forward, store, stop)Routes. A forward to an HTTP URL becomes an endpoint route; store and stop map to accept and reject.
Suppressions (bounces, unsubscribes, complaints)Suppressions per server, honored before every send.
Templates (handlebars)Templates, created from each template's active version through the server API.
Events (accepted, delivered, failed)Messages imported as completed records with --history, read from the Events API. Never re-sent.
WebhooksRSA-signed webhooks: MessageSent, MessageDelayed, MessageDeliveryFailed, MessageHeld. Recreate these by hand after the move.
Mailgun does not expose your existing sending API key or your DKIM private key over its API. So the migration creates a new CamelMailer credential (set it in your app) and a fresh DKIM key per domain (publish the DNS record CamelMailer shows). Everything else in the table above comes across as-is.

Run the migration

Install camelmailer-migrate and point it at Mailgun with --source mailgun. The --source-api-key is your Mailgun private API key. Add --source-region eu for the EU region, or --source-base-url for a custom host. As always, start with --dry-run to see the plan before anything is written.

Plan the migration (dry run)
camelmailer-migrate \
  --source mailgun \
  --source-api-key "$MAILGUN_API_KEY" \
  --source-region eu \
  --target https://app.camelmailer.com \
  --api-key "$CAMELMAILER_API_KEY" \
  --org acme \
  --dry-run

The target URL decides the rest. A *.camelmailer.com host is the hosted cloud and needs --org; any other host is a self-hosted install that uses the machine admin key. Drop --dry-run to run it.

Message history

Pass --history to import past messages from the Mailgun Events API. The tool reads accepted, delivered, and failed events per domain, groups them by message, and writes each as a completed record with its original timestamp and outcome. Mailgun does not return the original raw message over the Events API, so history carries synthesized headers rather than full bodies. Use --history-bodies headers or index to keep the import lean.

Include message history
camelmailer-migrate \
  --source mailgun \
  --source-api-key "$MAILGUN_API_KEY" \
  --target https://mail.example.com \
  --api-key "$CAMELMAILER_ADMIN_API_KEY" \
  --history --history-bodies headers

History is imported in batches (--history-batch, default 200) after the configuration. Nothing is ever re-delivered.

SMTP drop-in

If your app already posts to Mailgun over SMTP, CamelMailer is a straight relay. Create an SMTP-type credential on the server and use its key as the password:

SMTP settings
Host:  the SMTP hostname of your CamelMailer installation
Port:  587 (STARTTLS) or 25 (plain with STARTTLS); 465 for implicit TLS
Auth:  AUTH PLAIN or AUTH LOGIN
User:  any value (accepted but unused for these mechanisms)
Pass:  an SMTP-type credential key from the server

SMTP submission reaches the same pipeline as the HTTP API. See SMTP for the session details.

Cutover checklist

  • Run --source mailgun --dry-run and read the plan and the notes it prints.
  • Run it for real. The tool creates the server, domains, a fresh credential, suppressions, templates, and routes.
  • Set the new server API credential in your application, replacing the Mailgun key.
  • Publish each domain's verification, SPF, and DKIM records, then verify the domain and confirm the health check is green.
  • Recreate your webhook subscriptions and map the event names.
  • Optionally re-run with --history to bring past messages across.
  • Send a test message and confirm it is accepted and delivered.
  • Flip traffic, then keep the Mailgun account warm briefly before you close it.
Next steps: Sending email for the full send path, Credentials & routes for API and SMTP keys, and Sending domains for DNS and DKIM.