Authenticate your store’s email with Mailgun (SPF and DKIM)

Short answer: in your Mailgun account, open your sending domain and add the DNS records it lists at your DNS host: an SPF record (a fixed value, v=spf1 include:mailgun.org ~all, merged into the SPF record you already have) and a DKIM record (copied from “Domain Verification & DNS”). Then verify the domain in Mailgun and check it.

Reviewed

This page is for store owners whose store sends email through Mailgun, for example through an SMTP or mail plugin set to Mailgun. It follows Mailgun’s own documentation (Domain Verification), read on 2026-11-16. If Mailgun changes its pages, trust its pages over ours. For the general idea, see the SPF guide and the DKIM guide. Other services are on the hub page.

Symptom

You see one of these:

  • A checker or a mail provider says your store’s email fails SPF or is not DKIM signed, and your store sends through Mailgun.
  • Mailgun shows your domain as not verified.
  • Mailgun asks you to add DNS records and you do not know where they go.

Why it happens

Mailgun is a service that sends the email for you. Receiving servers want proof that Mailgun may send mail for your domain. You give that proof with records in DNS (the public address book of your domain), and Mailgun calls adding them “verifying” the domain.

Mailgun’s page says a verified domain also avoids a limit of 300 emails per day, so an unverified domain can stop mail even when nothing is wrong with your store.

The documentation page lists four records:

TypeWhat it is forValue on Mailgun’s page
TXT (SPF)Says which servers may send for your domainv=spf1 include:mailgun.org ~all
TXT (DKIM)Lets Mailgun sign your messagesShown in your Mailgun account, not on the page
CNAMEClick, open and unsubscribe trackingmailgun.org
MXLets Mailgun receive mail sent to the domain10 mxa.mailgun.org and 10 mxb.mailgun.org

A CNAME record points one name to another name. An MX record says which servers receive mail for a name.

Only the SPF value and the record types are fixed. Mailgun’s page does not give the host names (the “name” field) for these records. Your Mailgun account shows them for your domain.

Fix

  1. Open your domain in Mailgun. Log in to the Mailgun control panel and open the sending domain your store uses. If it is not there, add it first. The DNS records are in the section called “Domain Verification & DNS”. Mailgun also lets you get them through its API.
  2. Copy every record exactly as shown. For each one you need the type, the host (name) and the value. Copy them; do not retype them. If your DNS host adds your domain to the end of the host by itself, do not type the domain twice. See step 4 of the DKIM guide.
  3. Publish the SPF record, merged with what you have. A domain may have only one SPF record. Check first with the free checker.
    • If you have no SPF record, add a TXT record with this value:

“ v=spf1 include:mailgun.org ~all “

– If you already have one, do not add a second. Add include:mailgun.org inside the existing record, before the ~all or -all at the end. For example, v=spf1 include:_spf.example-host.com ~all becomes v=spf1 include:_spf.example-host.com include:mailgun.org ~all. Use the host Mailgun shows for the SPF record: Mailgun’s page does not say which one that is. See How to add or fix an SPF record for the one-record rule and for the 10 lookup limit.

  1. Publish the DKIM record. Copy the DKIM TXT record from “Domain Verification & DNS”. It is made for your domain, so there is no value to copy from this page. Mailgun may show more than one DKIM key. Its page says not every key has to be verified: Mailgun can sign as long as the key your domain’s setup needs is correct in DNS.
  2. Publish the tracking CNAME and the MX records if your account lists them. Mailgun’s page marks all four record types as required. Copy the host for each one from your account. General DNS advice, not from Mailgun’s page: do not add MX records for a name that already receives email you want to keep (for example your everyday mailbox) without checking with your email host first: an MX record decides where mail for that name is delivered. If your account does not list them for your domain, use what your account shows.
  3. Wait, then verify. Mailgun’s page says DNS changes “can take 24-48 hours” to fully spread. You can wait for Mailgun’s automatic check, press Verify DNS settings in the “Domain Settings” section of the control panel, or call Mailgun’s verify API. A verified domain shows a green “Verified” badge.

Check it worked

  1. Look for the badge. Your domain should show “Verified” in Mailgun.
  2. Run the free checker. Enter the domain your store sends from. The SPF line should show a valid record that contains include:mailgun.org. The DKIM line may say “Not checked”: the checker only tries common selector names and cannot know yours. That is not a failure. See “Check it worked” in the DKIM guide for how to look the key up yourself.
  3. Send a real test. Send an order email from your store to a mailbox at a large provider that is not your own sending account, open “show original” or the message source, and look for spf=pass and dkim=pass.

If it still fails

  • Not verified after two days. Compare the host and value of each record in your DNS host with the ones in Mailgun, character by character. A doubled domain name (...example.com.example.com) is the most common slip.
  • Two SPF records. A second SPF record breaks both. Merge them into one (see the SPF guide).
  • Some DKIM keys show “Unverified”. Mailgun’s page says this can happen after key changes or when extra keys exist, and that not all keys must be verified.
  • Mail still goes to spam. Authentication is one part of it. See WooCommerce emails not sending or going to spam.

How the plugin helps

Email Health Check & Log for WooCommerce reads the settings of popular SMTP plugins to guess which service your site sends through. If that is Mailgun, its SPF check warns when your SPF record does not seem to contain mailgun.org, and its fix text names include:mailgun.org and tells you to copy the DKIM TXT record from “Domain Verification & DNS” (it does not read or check your DKIM record against Mailgun, and it does not change your DNS). Get the plugin on WordPress.org.

Check your own domain

Type your domain into the free checker to see whether your SPF, DKIM and DMARC records are in place. Or install the free plugin, which checks the basics from inside your dashboard.