Key takeaways
- Start by reading the Authentication-Results header of a message you sent.
- If it shows spf=permerror, the record is malformed or duplicated.
- If it shows spf=fail or spf=softfail from a sender you expected to pass, the sender is missing from the record.
Most Mailgun SPF failures come from one of four causes: the record is missing at the name Mailgun sends from, there are two SPF records, the record exceeds the DNS-lookup limit, or the sending service is not in the list at all. Find the symptom in the table, run the check listed beside it, then apply the fix. The record syntax is covered in the setup guide.
Research checked: 12 November 2026
The short answer
Start by reading the `Authentication-Results` header of a message you sent. If it shows `spf=permerror`, the record is malformed or duplicated. If it shows `spf=fail` or `spf=softfail` from a sender you expected to pass, the sender is missing from the record. If there is no SPF result at all, the record is not published where the message's return-path domain looks for it.
Symptom table
| Symptom in the header | Likely cause | Check | Fix |
|---|---|---|---|
| `spf=none` | No SPF record at the return-path domain | `dig +short TXT <return-path domain>` returns nothing | Publish the TXT record at that exact name |
| `spf=permerror` | Two `v=spf1` records at one name | `dig +short TXT <domain>` returns two lines starting `v=spf1` | Merge them into one record |
| `spf=permerror` | More than 10 DNS-querying mechanisms | Count each `include:`, `a`, `mx`, `exists:` and `redirect=`, including nested ones | Remove unused senders or flatten carefully |
| `spf=fail` | Sending IP not authorised | Compare the sending IP with the record | Add the missing include, or stop sending from that service |
| `spf=softfail` | Sender not listed, but `~all` in use | Same as above | Add the sender; `~all` accepts the mail but flags it |
| `spf=pass` but DMARC fails | SPF domain does not align with From | Compare `smtp.mailfrom` with the From domain | Make DKIM aligned to the From domain, or send from a matching domain |
| Record looks right but no result changes | Stale DNS cache | `dig` against two resolvers; compare TTL | Wait out the TTL; do not keep editing |
Symptoms in detail
Symptom 1: No SPF result at all
Mailgun's verification guide states that DNS changes can take 24 to 48 hours to propagate. Check the name, not only the value. An SPF record placed on `example.com` does nothing for mail whose return-path is on `mail.example.com`. Query the return-path domain and confirm the record returns.
Symptom 2: permerror from duplicate records
RFC 7208 requires one SPF record per name, and says two records give a `permerror`. This is common after a second tool is connected and adds its own record. Run `dig +short TXT example.com` and look for more than one line beginning `v=spf1`. Keep one and move each sender's include into it.
Symptom 3: permerror from the lookup limit
RFC 7208 limits DNS-querying mechanisms to 10 during evaluation. Count by hand: each `include:` counts as one, and so does every mechanism inside the record it points to. A record that looks short can exceed the limit once nested includes are followed. Remove senders you no longer use, or ask each vendor for its current include.
Symptom 4: fail or softfail from a real sender
Find the IP the message came from in its `Received` headers. Check that IP falls within a range authorised by the record, or within a range from an include you have added. A common cause is a sending service that uses its own return-path domain, so SPF checks that domain instead of yours. Confirm which domain the header names as `smtp.mailfrom` before editing anything.
Symptom 5: SPF passes but DMARC fails
This is an alignment problem, not an SPF syntax problem. DMARC requires that the domain SPF checked, or the domain DKIM signed with, matches the visible From domain. RFC 7489 defines relaxed alignment as the default, so a subdomain can align with its parent. If the return-path is a third-party domain and DKIM is not aligned either, DMARC fails even with a clean SPF pass.
Symptom 6: the fix seems to work, then breaks
Keep a copy of the working record before editing. Change one thing at a time, and send one test after each change. If the record is correct but results flip between runs, check that you have not published two records on two resolvers during the change.