DKIM Check Failed: Public Key Could Not Be Retrieved (FortiMail)
FortiMail logs "DKIM Check Failed. The Public Key could not be retrieved or recognized." when it cannot get a usable key from the DNS name built from the message's selector and domain. Query that exact TXT record, then fix the selector, publish the missing record, or repair the damaged key value, and resend.
Sohail Hussain11 min readShort answer
- Read the s= and d= tags in the failing message's DKIM-Signature header, then query selector._domainkey.domain as a TXT record. The record is usually missing, published at the wrong name, or damaged.
- Publish or repair the record exactly as the signing service gives it. Then send a fresh test message, because old log entries stay failed.
- If the record looks correct from several public resolvers and only FortiMail fails, the receiving side's DNS lookup is the problem. Ask that FortiMail administrator to test the lookup from their unit.
You see this in a FortiMail log or report for a signed message:
DKIM Check Failed. The Public Key could not be retrieved or recognized.
It means FortiMail read the signature but could not get a usable key from DNS to check it against. The signature itself was never compared.
Why it happens
The standard describes how a verifier finds the key. All DKIM keys live under a subdomain called "_domainkey". For a signature with d=example.com and s=foo.bar, the query is for foo.bar._domainkey.example.com. The verifier handles two failure paths before any signature math. If the key record does not exist, the verifier must return a permanent failure (no key for signature). If the result is not in the defined format, it must ignore the key record and return a permanent failure (key syntax error). FortiMail's wording appears to cover both: nothing came back, or something came back that it could not recognize. I could not find a FortiMail document that spells out which internal conditions trigger this exact message, so treat that mapping as likely rather than confirmed.
The causes, most common first:
- The selector in the signature has no record. The sending service rotated to a new selector, you published a different one, or a DNS cleanup removed it.
- The record is malformed. It is truncated, has stray quotes or line breaks, or has an empty
p=(an empty key means revoked). - A CNAME points at a key that does not exist. This is common with providers that host the key for you.
- A wildcard TXT record answers instead of the key. The RFC notes that a wildcard TXT record covering the queried DKIM name will produce a response unlikely to be a valid DKIM key record.
- FortiMail's own DNS lookup fails. The record is fine publicly, but the unit's resolver times out or blocks large TXT answers. Microsoft's troubleshooting table lists the same pattern: a DKIM TXT record that is too large, or a slow authoritative DNS server, can cause lookup timeouts.
- Propagation or negative caching. You just changed the record and some resolvers still hold the old answer.
Step-by-step fixes
Fix 1: find the exact name FortiMail queried
- Open the failing message's raw headers (full source) and find the
DKIM-Signatureline. - Copy the
s=value (selector) and thed=value (signing domain). Thed=domain can differ from the visible From domain when a sending service signs for you. - Build the name as
{selector}._domainkey.{d-domain}, for exampleselector1._domainkey.example.com. - Query it from a machine you control:
dig +short TXT selector1._domainkey.example.com
nslookup -type=TXT selector1._domainkey.example.com
- Also check for a CNAME, since hosted keys often use one:
dig +short CNAME selector1._domainkey.example.com
A healthy TXT answer looks like this:
"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
If reading headers is slow, paste them into the email header analyzer. The email header glossary entry explains the fields.
Fix 2: publish the missing selector record
Use this when dig returns nothing or NXDOMAIN.
- In your sending platform or mail server, open its DKIM settings and confirm which selector it signs with now.
- If that differs from the
s=in the failing message, the failing mail was signed by an old or different configuration. Find which system produced it. - Publish the record exactly as that platform gives it, at
{selector}._domainkeyon your domain. Use the record type it specifies, TXT or CNAME. - Re-run the
digquery until it returns the record. - Send a new message to the FortiMail recipient and check the log again.
Fix 3: repair a damaged TXT record
Use this when dig returns something, but it looks wrong.
- Compare the value against the original from your provider or key generator.
- Remove any extra quote marks if your DNS panel adds its own.
- Make sure there are no spaces or line breaks inside the
p=value. - Confirm the record is not at a doubled name such as
selector1._domainkey.example.com.example.com. Panels that append the zone automatically want onlyselector1._domainkeyin the host field. - Make sure
p=is not empty. An empty value tells verifiers the key is revoked. - If you generate your own keys, our DKIM generator produces the record text, and the DKIM glossary entry covers the tags.
A 2048-bit key is longer than one 255-character DNS string. It must be split into several quoted strings inside one TXT record. The RFC says strings in a TXT record must be concatenated with no added characters before use, so a panel that inserts spaces between the pieces corrupts the key.
Only one record per selector
The RFC requires a selector name to resolve to a single key record. If you pasted a new record next to an old one at the same name, delete the old one instead of keeping both.
Fix 4: check CNAME-hosted keys
Microsoft 365 is the usual example. Its DKIM setup uses two CNAME records, selector1._domainkey and selector2._domainkey. Microsoft's documentation lists one common mistake: a TXT record containing the public key was created directly, instead of a CNAME pointing to Microsoft's DKIM infrastructure. If your provider hosts the key:
- Run the CNAME query from Fix 1 and note the target.
- Query that target for TXT. If it returns nothing, the provider side is not ready.
- Confirm DKIM signing is switched on in the provider's admin console. Microsoft's guidance for similar failures says to verify that DKIM signing is enabled and the DKIM DNS CNAME records exist.
- Compare the target hostname character by character with what the console shows.
Fix 5: check for a wildcard TXT record
If your zone has a wildcard TXT (*) record and no exact record for the selector, the lookup returns the wildcard's text, which is not a DKIM key. Publish the real selector record, or narrow the wildcard.
Fix 6: test FortiMail's own DNS path (receiving side)
Use this when the record resolves correctly from your laptop and several public resolvers, but FortiMail still fails.
- Check which DNS servers the unit uses and confirm they answer.
- Run a lookup for the exact selector name from the unit's own tools or CLI.
- Allow DNS over both UDP and TCP on port 53. Large TXT answers can need TCP, and a firewall that blocks it causes failures that look random.
- Retest with a fresh message.
If you are the sender, you cannot do this part. Send the receiving administrator the details from the support section below. One tip from a Microsoft support answer on a similar failure: if the key is published, verify DNS reliability and set the TTL to at least one hour to reduce timeout-related lookup failures.
Rotate keys without a gap
Publish the new selector before your sender starts signing with it. Keep the old selector record for a few days so queued mail still verifies.
Match the symptom to the cause
| What the selector query shows | Likely cause | Fix |
|---|---|---|
Empty answer or NXDOMAIN | Missing or wrong selector | Fix 2 |
Record present but cut off, or p= empty | Pasted wrong or key revoked | Fix 3 |
| CNAME whose target has no TXT | Provider key not enabled, or typo | Fix 4 |
A text answer without v=DKIM1 | Wildcard TXT answering | Fix 5 |
| Correct everywhere except FortiMail | Receiver DNS or TCP blocked | Fix 6 |
| Different answers from different resolvers | Propagation or caching | Wait out TTL, retest |
Propagation deserves a note. A resolver that cached a "does not exist" answer can keep returning it until the zone's negative-caching time expires, and a changed record can serve the old value until its TTL runs out. Query more than one public resolver before you conclude the record is wrong.
Checklist before you try again
- The selector and domain come from the failing message's header, not from memory.
dig TXTon the exact name returns one record starting withv=DKIM1.p=is present, complete and not empty.- No doubled domain name in the record host.
- If the key is CNAME-hosted, the target resolves to a TXT record and signing is enabled at the provider.
- You tested with a new message sent after the change.
If nothing works
If the record is correct from several public resolvers, the issue is on the receiving side. Contact the recipient organization's mail administrator, or Fortinet support if you run the FortiMail unit. If you sign through Google Workspace or Microsoft 365, check their admin console for the signing status and selector in use before opening a ticket.
Include the full raw headers of one failing message, the dig output for the selector name, timestamps with timezone, and the FortiMail log line with the error text.
Subject: DKIM check failure: public key could not be retrieved or recognized
Hello,
FortiMail logged "DKIM Check Failed. The Public Key could not be retrieved or recognized." for mail from {your-domain}.
Selector (s=): {selector}
Signing domain (d=): {your-domain}
Record queried: {selector}._domainkey.{your-domain}
Result from public resolvers (dig output attached): {paste output}
Failure timestamps (with timezone): {timestamps}
Raw headers of one failing message are attached.
Could you run a TXT lookup for that name from your FortiMail unit and confirm that DNS over UDP and TCP port 53 is allowed to its resolvers?
Thank you,
{name}
Where Mailneo fits
Mailneo can't fix a FortiMail receiver's DNS lookups, and it can't change your DNS; you edit records at your registrar or DNS host. What it does cover is the sender side. For mailboxes you connect, it looks up your sending domain's SPF, DKIM and DMARC records and checks whether they authorize the provider you use, so a missing selector can show up before a recipient's gateway logs it. See the email accounts documentation. For a single message, the free email header analyzer works without an account. The SPF, DKIM and DMARC setup guide covers all three records.
For the record format itself, see the DNS binding in RFC 6376, and Microsoft's guide to DKIM CNAME setup and troubleshooting if you sign through Microsoft 365.
Common questions
Does this error mean the message was rejected?
Not by itself. It is a DKIM check result. What FortiMail does next (reject, quarantine, tag or pass) depends on the profile configured on the receiving unit. The RFC also says verifiers should not decide message acceptability solely on an unverifiable signature.
Is this the same as a body hash mismatch?
No. A body hash failure means the key was found but the message changed after signing. This error is earlier: the key was not found or not understood. If dig returns a proper v=DKIM1 record and you still see failures, look at what changed the message in transit, such as a footer or a content-rewriting gateway.
Should a missing key return a temporary or permanent failure?
It depends on the cause. Under the RFC, a lookup that gets no response may be treated as temporary, while a record that does not exist is a permanent failure. A DNS timeout on FortiMail's side can therefore look like a missing key; Fix 6 is the check for that.
How long until the fix shows up?
A new record can appear almost immediately, but cached negative answers and old TTLs can delay it. Query more than one public resolver and send a fresh test message rather than re-reading old logs.
Explore: Email Deliverability
Related Articles
0x800ccc0e: Outlook Unable to Connect to SMTP Server, Fixed
Outlook error 0x800ccc0e means the app could not open a connection to your outgoing (SMTP) server. Usually the port, encryption setting or password is wrong, or antivirus, a firewall or your ISP is blocking it. Set port 587 with STARTTLS, turn on SMTP authentication, and test again.
SocketLabs "421 4.5.1 Too many errors" blacklist: how to fix it
`421 4.5.1 Too many errors, you have been temporarily blacklisted` means a SocketLabs server saw repeated auth or bad-address errors from your IP and paused it. Stop whatever is retrying, fix credentials and invalid recipients, clear the queue, and wait. The block usually lifts within minutes, but returns if retries resume.
421-4.7.0 Gmail Has Detected This Message Is Suspicious: Fix
The 421-4.7.0 "suspicious due to the nature of the content and/or the links" error means Gmail's content filter rejected your message after DATA, not an authentication check. Remove click tracking or move it to your own domain, drop URL shorteners, check link reputation, then retest with a plain message.
421 4.7.0 IP not in whitelist for RCPT domain: what it means
The error 421 4.7.0 IP not in whitelist for RCPT domain means the recipient's mail gateway, usually Mimecast in reports, only accepts connections from approved IPs, and the Google sending IP isn't on that list. The fix is on the recipient side: their admin must allow the IPs or change the mail routing.
Ready to supercharge your email marketing?
Start sending smarter emails with AI-powered campaigns. No credit card required.
Get Started Free