Three records, three questions
A receiving server asks three things about every message, and each record answers one:
| Record | Question it answers | Domain it checks | Where it lives |
|---|---|---|---|
| SPF | May this IP send mail for this domain? | The envelope sender (Return-Path, MAIL FROM), not the From you see. | TXT on that domain. |
| DKIM | Was this message signed by the domain, and is it unchanged? | The d= domain of the DKIM-Signature header. | TXT (or CNAME) at selector._domainkey.domain. |
| DMARC | Does a passing SPF or DKIM belong to the domain in the From, and what if not? | The From header domain, the one the reader sees. | TXT at _dmarc.domain. |
SPF and DKIM on their own can pass for any domain: a spammer can authenticate spammer.example perfectly and put your domain in the From. DMARC closes that gap by requiring that at least one of them passes for a domain aligned with the From.
SPF
SPF (RFC 7208) lists which servers may use a domain as the envelope sender. It is a single TXT record:
bounce.example.com. TXT "v=spf1 include:_spf.provider.example ip4:203.0.113.10 ~all"include:adds another domain's SPF (your sending service's);ip4:andip6:list addresses directly;mxandaauthorise the domain's own servers.~all(softfail) or-all(fail) says what to do with everything else. With DMARC in place,~allis enough: DMARC decides.- One SPF record per name. Two
v=spf1records on the same name are a permanent error: merge them.
SPF checks the Return-Path domain, which many services set to their own domain. For SPF to count for DMARC, the Return-Path must be your domain or a subdomain of it (a custom MAIL FROM such as bounce.example.com).
The 10-lookup SPF limit
To keep evaluation cheap, RFC 7208, section 4.6.4 caps an SPF check at 10 DNS lookups. If the record needs more, the result is permerror and, for DMARC, SPF simply does not pass.
- They count:
include,a,mx,ptr,existsand theredirectmodifier, including every one nested inside the included records. - They do not count:
ip4,ip6,allandexp. - Void lookups (names that do not exist or return nothing) should be limited to two; beyond that, also
permerror.
The usual way to blow the limit is stacking services on the root domain: office mail, CRM, helpdesk, newsletters, each with its own include that in turn includes others. How to fix it:
- Remove the includes of services you no longer use.
- Give each sending service its own MAIL FROM subdomain (
bounce.example.com,mail.example.com): each subdomain has its own SPF record and its own 10 lookups. - Do not use
ptr(the RFC itself discourages it) and avoidaandmxif those servers do not send. - Flatten (replace includes with
ip4/ip6) only for ranges you control: a provider's IPs change without notice. - Count your lookups with the email authentication checker: it follows includes and redirects and tells you when you pass 10.
DKIM
DKIM (RFC 6376) signs each message with a private key; the public key is published in DNS under a selector, so a domain can have several keys at once (one per service, or old and new during a rotation):
s1._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A..."The signature travels in a header of the message. The two fields that matter for deliverability are d=, the signing domain that DMARC compares with the From, and s=, the selector to look up:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=s1;
h=from:to:subject:date:message-id; bh=...; b=...- Use RSA keys of 2048 bits. RFC 8301 requires at least 1024 and Gmail asks for 1024 or more, recommending 2048.
- Many services publish the key for you and ask you to create a CNAME to their DNS: that way they can rotate it without you touching anything.
- DKIM survives forwarding better than SPF (the forwarder's IP is not in your SPF), which is why aligned DKIM is the more robust half of DMARC.
DMARC
DMARC (RFC 9989, which in May 2026 replaced RFC 7489) publishes your policy and where to send reports:
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:dmarc@example.com"p=- What to do with mail that fails:
none(only report),quarantine(spam folder) orreject. rua=- Where to send the daily aggregate reports. Without it you are flying blind.
sp=andnp=- Policy for subdomains and for subdomains that do not exist (useful against made-up subdomains).
adkim=andaspf=- Alignment mode,
r(relaxed, the default) ors(strict). t=- New in RFC 9989:
t=ymarks a policy you are still testing. It replaces the oldpcttag, which the new specification removes.
A message passes DMARC if SPF or DKIM passes and the domain that passed is aligned with the From. Only one record is allowed at _dmarc: two make the policy invalid.
Alignment, with examples
In relaxed mode, two domains are aligned when they share the organizational domain (bounce.example.com and example.com are). In strict mode they must be identical. With From news@example.com:
| Return-Path | DKIM d= | Result (relaxed) |
|---|---|---|
bounce.example.com, SPF pass | example.com, pass | DMARC pass, both aligned. |
provider.example, SPF pass | example.com, pass | DMARC pass through DKIM. SPF passes but is not aligned. |
provider.example, SPF pass | provider.example, pass | DMARC fail: everything passes, nothing is aligned. |
bounce.example.com, SPF pass | none | DMARC pass through SPF, but a forward will break it. |
The third row is the classic case of a service that “works” until you publish p=quarantine: aggregate reports show it before it hurts.
From p=none to p=reject
- Inventory. List everything that sends as your domain: office mail, your app, newsletters, invoicing, helpdesk, the website's forms.
- Publish
p=nonewithruaand let reports accumulate for two to four weeks, long enough to see monthly sends. - Fix each legitimate source until it passes aligned: DKIM with your domain, and custom MAIL FROM where the service allows it.
- Move to
p=quarantine. If you want to be cautious, publish it first witht=yand watch the reports. - Move to
p=rejectwhen the reports only show failures from sources that are not yours. Keep reading them: new services appear.
Gmail, Yahoo and Outlook.com accept p=none; reject is what stops others from sending in your name. Domains that never send mail can go straight to v=DMARC1; p=reject with v=spf1 -all.
Reading aggregate reports
Aggregate reports (RFC 9990) are XML files, usually compressed and sent once a day by each provider that receives your mail. They contain no message content: for each source IP, how many messages it sent as your domain and how SPF, DKIM and DMARC came out. One record looks like this:
<record>
<row>
<source_ip>203.0.113.25</source_ip>
<count>1250</count>
<policy_evaluated>
<disposition>none</disposition>
<dkim>pass</dkim>
<spf>fail</spf>
</policy_evaluated>
</row>
<identifiers><header_from>example.com</header_from></identifiers>
<auth_results>
<dkim><domain>example.com</domain><selector>s1</selector><result>pass</result></dkim>
<spf><domain>provider.example</domain><result>pass</result></spf>
</auth_results>
</record>How to read it: 1,250 messages from 203.0.113.25 with From example.com. DKIM passed with d=example.com (aligned), so DMARC passes. SPF passed too, but for provider.example, the service's own Return-Path, which is not aligned: that is why policy_evaluated shows it as fail. The fix is a custom MAIL FROM at that service. What to look for:
- Your sources failing: a service of yours without DKIM for your domain or with its own Return-Path. Fix it before tightening the policy.
- Sources you do not recognise: spoofing or a forgotten service. With
p=reject, they stop reaching inboxes. - Forwarding: SPF fails on the forwarder's IP and DKIM passes: normal, and the reason to always sign with DKIM.
Raw XML is hard to read in volume: a mailbox just for reports and a parser or a DMARC reporting service save you time.
How Hermaily handles it
- Aligned DKIM. Each verified domain gets three DKIM CNAME records with 2048-bit keys that sign with your domain, so DKIM aligns with your From.
- Aligned SPF without touching your root record. Hermaily uses a MAIL FROM subdomain of yours, with its own SPF and MX records: SPF aligns in relaxed mode, it uses up none of the 10 lookups of your main domain, and bounces come back to Hermaily.
- DMARC from the assistant. If you have no DMARC, it proposes
v=DMARC1; p=none; rua=mailto:dmarc@yourdomain; if you have two records, it tells you to keep one; if you are onp=rejectbefore DKIM and SPF are right, it warns you that your mail would be rejected. - Clear errors. When a record is missing or wrong, the assistant says which one and with what value, including when SPF has several records that must be merged.
Frequently asked questions
Do I need SPF, DKIM and DMARC or is one enough?
To send to Gmail, Yahoo or Outlook.com in volume you need all three: SPF and DKIM passing and a DMARC record. DMARC only needs one of the two aligned, but having both makes delivery more robust, for example when a message is forwarded.
What happens if my SPF record has more than 10 lookups?
The SPF check returns permerror and, for DMARC, SPF does not pass. If DKIM passes aligned, the message still passes DMARC, but you have lost the backup. Remove unused includes or move services to their own subdomains.
Can I have two SPF records?
No. Two v=spf1 records on the same name are a permanent error. Merge the mechanisms into one record, or give each service its own subdomain.
How long should I stay on p=none?
Long enough for the reports to show every legitimate source passing aligned: usually two to four weeks, more if you have senders that only send once a month.
Does the new DMARC RFC change my record?
A v=DMARC1 record with p, rua, sp and the alignment tags is still valid under RFC 9989. The pct tag is removed: if you use it, replace it with t=y while you test, or drop it.
Get the three records right the first time
The assistant gives you DKIM, SPF and DMARC for your domain and checks them for you.