All articles
    Deliverability

    How to Set Up a DKIM Record for Mailgun

    To set up DKIM for Mailgun, copy the DKIM record from the Domain Verification & DNS section of your domain in the Mailgun control panel, publish it exactly…

    VeriMailX Team November 23, 2026 3 min read

    Key takeaways

    • Open the domain in Mailgun under Sending, then Domains, and find Domain Verification & DNS.
    • Check whether the domain shows CNAME records (Automatic Sender Security) or a TXT record (manual).
    • Create the record at the exact name shown.

    To set up DKIM for Mailgun, copy the DKIM record from the Domain Verification & DNS section of your domain in the Mailgun control panel, publish it exactly as shown at the name Mailgun gives, then confirm it with `dig`. Mailgun offers two modes: Automatic Sender Security, which uses CNAME records, and manual key rotation, which publishes the public key as a TXT record. Check which one your domain uses before you add anything.

    Research checked: 12 November 2026

    This guide covers setup only. Planning key rotation for cold sending and fixing failed signatures are covered in the other two DKIM guides.

    The short answer

    1. Open the domain in Mailgun under Sending, then Domains, and find Domain Verification & DNS.
    2. Check whether the domain shows CNAME records (Automatic Sender Security) or a TXT record (manual).
    3. Create the record at the exact name shown. Paste the value without adding your domain a second time.
    4. Verify with `dig`, then click Verify DNS settings in the domain settings.

    Setup steps

    Step 1: Identify your mode

    Mailgun's DKIM security page describes both paths:

    • Automatic Sender Security is enabled during setup for new domains. It creates two 2048-bit selector records as CNAMEs that point to Mailgun's infrastructure, and it rotates keys every 120 days by default. You do not update DNS on rotation.
    • Manual rotation publishes the public key directly as a TXT record. You can have Mailgun generate a 1024-bit or 2048-bit key.

    Existing TXT-based domains can switch to Automatic Sender Security from the DNS records page.

    Step 2: Publish the record

    For a manual TXT record, the name follows the pattern `<selector>._domainkey.<your domain>`, where the selector is the one Mailgun displays. The value begins `v=DKIM1; k=rsa; p=` followed by the public key. Copy the entire value from the control panel rather than typing it.

    A 2048-bit key is longer than many DNS hosts accept in one string. Mailgun's documentation notes that some providers need the record split into two quoted parts. Split it only if your host requires it, and rejoin the parts into one value when you check the answer.

    For Automatic Sender Security, the records are CNAMEs. Enter only the hostname portion your DNS host expects; if your host appends the domain automatically, a full name will double it.

    Check and confirm

    Step 3: Verify with dig

    For a TXT record:

    ``` dig +short TXT <selector>._domainkey.example.com ```

    The output should begin with `"v=DKIM1; k=rsa; p=` and contain the same key string as the control panel. For a CNAME setup, `dig +short CNAME` should return the Mailgun target shown in the panel.

    Step 4: Confirm signing

    Send a test message and open its headers. Look for a `DKIM-Signature` header with `d=` set to your sending domain and `s=` set to the selector you published. Then check `Authentication-Results` for `dkim=pass`. Compare the `d=` value with the domain in your From address. If they differ, DMARC can still pass when the two align under the relaxed rule, which RFC 7489 uses by default, but a mismatch is worth understanding before you rely on it.

    Mailgun may list more than one DKIM key, and some can show as unverified. That is expected as long as the key your domain signs with is correctly published. If the signature names a selector that is not in DNS, the check fails even though other keys verify.

    Step 5: Verify in Mailgun

    Click Verify DNS settings in the Domain Settings section, or call Mailgun's verify endpoint. A verified domain shows a green Verified badge. If the badge does not appear, check the DNS answer first, then wait for propagation, which Mailgun says can take 24 to 48 hours.

    Frequently asked questions

    Keep reading

    Comparisons

    Instantly vs Smartlead: How to Choose a Cold Email Platform

    Instantly and Smartlead both support cold email campaigns across multiple sending accounts. The better choice depends on your contact limits, sending volume, reply workflow, and the cost of the features you actually need. Start

    Read
    Comparisons

    Instantly vs Smartlead Deliverability: How to Compare Inbox Placement

    Neither Instantly nor Smartlead can guarantee that a cold email reaches the inbox. Both provide tools for managing outreach, but inbox placement also depends on your sending domain, authentication, recipient list, message and the

    Read
    Comparisons

    Instantly vs Smartlead Pricing: Compare the Real Cost of Outreach

    The headline subscription is only one part of a cold email budget. The right comparison includes sending limits, contact storage, mailboxes, lead data, verification and any tools needed for your team. A cheaper entry plan can

    Read