SPF, DKIM and DMARC: Why OTP Emails Land (or Don't)
Developer
By the zephbox teamPublished 4 min read
How we write these: product details are checked against the current zephbox API and site behavior on the date shown. Spotted a mistake? Tell us and we correct it (editorial policy).
An OTP email lands in the inbox when the receiving server can verify that your domain really sent it and trusts your sending reputation. That verification rests on three DNS-based standards: SPF (which servers may send for your domain), DKIM (a cryptographic signature on the message) and DMARC (the policy that ties both to the visible From address). When a verification email never arrives, a missing or misaligned record is among the first things to check. This guide explains each, shows what correct records look like, and lists the failure modes that specifically hit one-time-code mail.
The three records in one table
| Standard | Question it answers | Where it lives | Typical failure |
|---|---|---|---|
| SPF | Is this server allowed to send mail for the envelope domain? | A TXT record on the domain | Provider not included; more than 10 DNS lookups; two SPF records |
| DKIM | Was the message signed by the domain and not altered? | A public key in a TXT record at selector._domainkey.domain; a signature header on each message | No signing enabled; selector or key missing from DNS; body modified in transit |
| DMARC | Do SPF or DKIM pass for the domain in the From address, and what should the receiver do if not? | A TXT record at _dmarc.domain | No record; alignment failure with a third-party sender; policy set too strict too soon |
DMARC requires alignment: the domain that passed SPF or DKIM must match the domain in the visible From header (exactly or, in relaxed mode, share the organizational domain). A third-party email service can pass SPF for its own domain and still fail DMARC for yours.
What correct records look like
These use example.com and a made-up provider; yours will differ, and your email provider's documentation gives the exact values.
; SPF - one TXT record at the root, ending in an all-mechanism
example.com. TXT "v=spf1 include:_spf.mailprovider.example -all"
; DKIM - public key published under a selector your provider gives you
s1._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkq...(public key)..."
; DMARC - start in monitoring mode and read the reports
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:[email protected]"Check them from a shell with dig +short TXT example.com, dig +short TXT s1._domainkey.example.com and dig +short TXT _dmarc.example.com. Rolling DMARC out safely means starting at p=none, reading the aggregate reports until every legitimate sender passes, then moving to quarantine and finally reject.
Failure modes that specifically hurt OTP mail
- Shared sending IP with a poor reputation. Transactional mail sent from a pool shared with bulk marketers inherits their problems. A dedicated or reputable transactional stream, ideally on its own subdomain (for example
mail.example.com), keeps OTP mail separate from marketing. - DMARC alignment failure on a third-party sender. Your app uses a provider that signs with its own domain. SPF and DKIM pass for the provider, but not for you, so DMARC fails and strict receivers reject. Configure the provider to sign with your domain.
- SPF over the 10-lookup limit or duplicate records. Adding every vendor via
includepushes you past the limit, and the whole record is treated as an error. Only one SPF TXT record is allowed. - Forwarding breaks SPF. When a recipient's address forwards to another provider, the forwarding server is not in your SPF record. DKIM survives forwarding if the message is unmodified, which is why DKIM matters.
- Content that looks like phishing. Urgent wording, URL shorteners, mismatched link text and heavy images can push an authenticated message into spam. Keep OTP mail short, plain and from a consistent address.
- Tracking links. Link rewriting on a domain with poor reputation can trigger filters. For verification links, avoid third-party click tracking.
- Greylisting and delays. Some servers defer first-time senders. A code that arrives after your validity window is useless, so consider a window of a few minutes and a resend option.
Diagnosing with a real inbox
Authentication results are written into the received message's headers (an Authentication-Results header with spf=pass, dkim=pass, dmarc=pass or the failures). The reliable method is to send a test message to a mailbox where you can view the original headers, and read those lines. A temporary inbox is useful here in a different way: it tells you whether the mail arrived at all, how long it took and what the body looks like, across a mainstream provider's infrastructure. Note that the zephbox API returns the sender, subject, text and HTML body, not raw headers, so use a mailbox that exposes headers for the authentication verdicts, and a temporary inbox for arrival, timing and content. The test pattern is in the QA checklist and the automated version in OTP automation.
Glossary
- Envelope sender (Return-Path)
- The address mail servers use for bounces and SPF checks. It can differ from the visible From.
- Header From
- The address people see; DMARC aligns SPF and DKIM against this domain.
- Selector
- A label that lets a domain publish several DKIM keys, for rotation or multiple providers.
- Alignment
- The match between the authenticated domain and the Header From domain.
- Aggregate report (rua)
- A daily XML summary from receivers showing which sources sent mail as your domain and whether they passed.
- ARC
- A mechanism that lets forwarders preserve earlier authentication results.
A short checklist
- One SPF record, under the lookup limit, ending in
-allor~allonce you are confident. - DKIM enabled for your domain at the provider, key published and rotated periodically.
- DMARC at
p=nonewith reports until clean, then tightened. - Transactional mail on its own stream or subdomain.
- Short, plain OTP messages; no shorteners; resend available.
- Bounce and complaint monitoring, with hard bounces suppressed (why).
Frequently asked questions
Do I need all three of SPF, DKIM and DMARC?
Major mailbox providers expect authenticated mail, and bulk senders are required by some to have all three. For OTP mail, DKIM aligned with your domain is the most valuable single piece.
Why do OTP emails go to spam even when SPF and DKIM pass?
Authentication is necessary but not sufficient. Reputation of the sending IP and domain, content and recipient engagement also matter.
Can I check my records for free?
Yes, with dig or nslookup, and free online checkers, and by reading the Authentication-Results header on a delivered test message.
Gmail & Outlook Temp Mail That Services Can't Block
95%+ acceptance rate for Facebook, Instagram, Netflix & OTP signups.
Try zephbox Premium →