Skip to main content
AhaSend migration from Mailgun means changing your send call or SMTP settings, mapping delivery events and carrying blocked recipients across before moving traffic.

Prepare the AhaSend Account

Verify the sending domain and create a domain-scoped send-only v2 key or SMTP credential. Keep the old provider active while you test. Record your existing templates, headers, tracking choices, sender addresses, jobs and suppression rules so you can compare behavior.

Map the API Fields

Use the AhaSend Create Message endpoint with v2 authentication. This is a field mapping from Mailgun’s send API, not a drop-in change of base URL. AhaSend Create Message returns HTTP 202 with a result for each recipient; check each status, including error, instead of treating the request as all-or-nothing. Follow send examples for an actual sandbox call. Keep a stable business-event idempotency key with an unchanged payload and separate keys for sandbox and live work. Review schedule limits before moving future jobs.

Replace the SMTP Settings

Replace your Mailgun region’s SMTP host and domain SMTP credentials with AhaSend’s host and a new AhaSend SMTP credential. Do not reuse a Mailgun API key or domain password. Review region-specific source settings in Mailgun’s SMTP guide. See SMTP settings for all hosts, ports, TLS requirements and limits. Keep your existing mail library and change its transport configuration; use the language examples to test.

Map Events by Meaning

These are the closest matching outcomes, not identical payloads or a guaranteed one-to-one event sequence. Keep the provider name with each saved message ID while both systems are active. See Mailgun’s event documentation and the AhaSend event list. Create a separate AhaSend webhook configuration and replace the old verification code with AhaSend signature checks. Parse AhaSend’s payload shape, deduplicate by its delivery header, and acknowledge verified unknown event types with 2xx. Do not reuse the old provider’s signing secret, retry assumptions or event IDs.

Export the Old Recipient Blocks

Export bounces, complaints and unsubscribes for every Mailgun sending domain you are moving. Preserve Mailgun unsubscribe tags or list scopes in your app, then decide which blocks should apply to a whole AhaSend sending domain. Use the list operations in Mailgun’s Bounces API, Complaints API and Unsubscribe API. Follow pagination rather than assuming the first page contains the full list.

Import Suppressions Before Switching Traffic

Export blocked addresses using the old provider’s options described above. Include hard bounces, complaints, unsubscribes and application-level opt-outs; deduplicate by address and sending domain without losing the reason. Keep the original export and your application’s durable preferences. A provider change is not permission to mail an opted-out address again. Normalize the export into a CSV with email,domain,reason,expires_at columns. domain is the AhaSend sending domain, not the recipient’s domain. This sample row is a format template; replace both placeholders. Select an expiry that preserves your block policy, and keep permanent opt-outs blocked in your own app beyond that time. See suppression durations.
suppressions.csv
Use Python 3.13 or newer; the script needs no third-party packages. Set AHASEND_ACCOUNT_ID and AHASEND_IMPORT_KEY, a separate full API key with suppressions:write. This is a real management operation: sandbox mode does not apply to suppressions. First test with a unique address on your test sending domain, then verify it with List Suppressions. Save the following as import_suppressions.py. It validates the whole CSV before making changes and stops on the first failed request. It requires an explicit domain so an empty cell cannot broaden the import to all domains.
import_suppressions.py
Run python import_suppressions.py suppressions.csv. An existing suppression can return 409: compare its domain, reason and expiry before deciding what to do. Do not delete it just to make the import pass. A stopped run may have imported earlier rows, so keep the progress output and reconcile uncertain requests. Exact retries reuse a stable idempotency key; after its time limit, verify existing records before retrying. Keep imports within API rate limits.

Switch Traffic in Small Steps

  1. Verify the AhaSend domain and leave the old provider’s required DNS in place while it still sends. Test the new code in sandbox mode, including failure and suppression paths.
  2. Keep your message templates in your app or adapt them explicitly. Provider template IDs, recipient lists, request IDs and signing secrets do not transfer to AhaSend automatically.
  3. Import suppressions, then update your saved recipient preferences. Repeat the export/import for changes made since the initial snapshot before moving each traffic group.
  4. Route each new job to exactly one provider. Keep that choice, the saved payload and your application event ID with the job so a retry cannot silently switch providers and duplicate it.
  5. Move a small group of expected mail, compare acceptance, bounces and delivery delays, and increase only when results remain stable. Follow deliverability and warm-up guidance.
  6. Keep receiving old-provider events for in-flight messages. If you roll back, route only new unsent jobs back and preserve all new suppressions. Retire old credentials, DNS and event handlers after old work has finished.