A working SPF, DKIM and DMARC setup takes three DNS records and one rollout plan: a single SPF TXT record at your domain listing every service allowed to send as you (staying under 10 DNS lookups), DKIM signing turned on at each of those services with 2048-bit keys published under selector._domainkey, and a DMARC record at _dmarc.yourdomain that starts at p=none with aggregate reports (rua=) and moves to quarantine and then reject once the reports show all legitimate mail passing with alignment. Since 2024, Gmail and Yahoo require all three from anyone sending 5,000 or more messages a day, and Outlook.com has rejected non-compliant high-volume mail since May 5, 2025, so this is no longer optional for most businesses.

This guide covers record syntax with real examples, the SPF lookup limit and why flattening is riskier than it looks, DKIM key sizes and rotation, a DMARC rollout schedule, the May 2026 DMARC specification update, and how to verify everything with dig and message headers.

How an SPF, DKIM and DMARC Setup Fits Together

Each one answers a different question, and only DMARC looks at the address your recipients actually see.

What it checks Domain it authenticates Where it lives
SPF Is the sending IP allowed to send for this envelope domain? MAIL FROM (the Return-Path / bounce address) TXT at the domain
DKIM Was the message signed by a key this domain published, and is it unaltered? The d= value in the DKIM-Signature header TXT at selector._domainkey.domain
DMARC Did SPF or DKIM pass for a domain that matches the visible From:? The From: header domain TXT at _dmarc.domain

The concept that trips people up is alignment. SPF can pass for bounces.mailvendor.net and DKIM can pass for mailvendor.net while your From: header says news@example.com; DMARC still fails, because neither authenticated domain matches yours. Under RFC 9989 the default is relaxed alignment (aspf=r, adkim=r): the authenticated domain and the From: domain must share the same organizational domain, so mail.example.com aligns with example.com. Strict mode (s) requires an exact match. DMARC passes if either SPF or DKIM passes with alignment.

In practice, DKIM alignment is the one to rely on. SPF breaks on plain forwarding because the forwarder's IP is not in your record, and many SaaS senders use their own bounce domain, so SPF alignment is often impossible unless you configure a custom Return-Path.

Step 1: Inventory Everything That Sends as Your Domain

Before writing a single record, list every system that puts your domain in a From: header:

  • Your mailbox provider (Google Workspace, Microsoft 365, or a self-hosted MTA)
  • Marketing and newsletter platforms
  • Transactional senders (password resets, receipts) such as your app's email API
  • Helpdesk, CRM, billing, HR and calendar tools that send "from" you
  • Servers and scanners that send alerts directly over SMTP

Missing one is the most common way a DMARC rollout causes damage. The aggregate reports in Step 4 will reveal the ones you forgot, which is exactly why you start in monitoring mode. When choosing a domain for a new company, it is worth planning separate subdomains for marketing and transactional mail from day one.

Step 2: SPF Record Setup

SPF syntax with an example

example.com.  3600  IN  TXT  "v=spf1 include:_spf.google.com include:sendgrid.net ip4:198.51.100.25 -all"

Reading left to right: version v=spf1; authorize whatever Google's and SendGrid's published records authorize; authorize one on-premises server by IP; and -all fails everything else. Use ~all (softfail) while you are still discovering senders, and -all once you are confident. With DMARC at enforcement, the difference matters less than people think, because DMARC decides the outcome, but -all is the cleaner end state.

Rules that cause real outages:

  • Exactly one SPF record per domain. RFC 7208 says that if more than one v=spf1 record exists, the result is permerror. Adding a second TXT record for a new vendor instead of merging is a classic mistake.
  • Do not use ptr. The RFC's section heading is literally "ptr" (do not use).
  • SPF applies per hostname. A record on example.com does not cover mail.example.com. Subdomains that send need their own record, and subdomains that never send should publish v=spf1 -all.

The 10 DNS lookup limit

RFC 7208 section 4.6.4 is precise: the include, a, mx, ptr and exists mechanisms and the redirect modifier cause DNS queries, implementations "MUST limit the total number of those terms to 10", and exceeding the limit returns permerror. Nested includes count, ip4, ip6 and all do not, and there is a separate limit of two "void lookups" (queries that return no records). A permerror usually means DMARC sees SPF as failed for every message.

Because each vendor's include can contain its own includes, you have to count recursively. This script does that with dig:

"""Count the DNS-querying terms in an SPF record, recursively (RFC 7208 4.6.4 limit: 10).
Usage: python3 spf_count.py example.com [resolver-ip]   (needs `dig` on PATH)"""
import subprocess, sys

RESOLVER = sys.argv[2] if len(sys.argv) > 2 else '1.1.1.1'

def spf_record(domain):
    out = subprocess.run(['dig', '+short', '+time=3', '+tries=3', 'TXT', domain, '@' + RESOLVER],
                         capture_output=True, text=True).stdout
    for line in out.splitlines():
        txt = ''.join(part for part in line.split('"') if part.strip())  # join split TXT strings
        if txt.lower().startswith('v=spf1'):
            return txt
    return None

def walk(domain, depth=0):
    rec = spf_record(domain)
    if rec is None:
        print('  ' * depth + f'{domain}: no SPF record (counts toward the void-lookup limit)')
        return 0
    total = 0
    for term in rec.split()[1:]:
        t = term.lstrip('+-~?').lower()
        if t in ('a', 'mx', 'ptr') or t.startswith(('a:', 'a/', 'mx:', 'mx/', 'ptr:', 'exists:', 'include:', 'redirect=')):
            total += 1
            print('  ' * depth + f'+1 {term}')
            if t.startswith('include:'):
                total += walk(t.split(':', 1)[1], depth + 1)
            elif t.startswith('redirect='):
                total += walk(t.split('=', 1)[1], depth + 1)
    return total

n = walk(sys.argv[1])
print(f'{sys.argv[1]}: {n} DNS-querying terms -> {"OK" if n <= 10 else "permerror (limit is 10)"}')

When I ran it against github.com on December 2, 2026, the domain was using exactly its full budget:

+1 include:spf.protection.outlook.com
+1 include:_netblocks.google.com
+1 include:_netblocks2.google.com
+1 include:mail.zendesk.com
+1 include:_spf.salesforce.com
  +1 exists:%{i}._spf.mta.salesforce.com
+1 include:servers.mcsv.net
+1 include:mktomail.com
+1 include:sendgrid.net
  +1 include:ab.sendgrid.net
github.com: 10 DNS-querying terms -> OK

That is typical of a company with many SaaS senders: one more vendor, or one vendor adding a nested include to its own record, and every message fails SPF. The script also shows a subtle parsing detail: GitHub's record is longer than 255 characters, so DNS returns it as two quoted strings that must be joined without a space (include:servers. + mcsv.net).

SPF flattening risks

"Flattening" replaces includes with the IP ranges they currently resolve to, which gets you under the limit. The risk is that the vendor's IPs change and your copy does not; new sending IPs silently fail SPF until someone notices. If you flatten, automate it and monitor it, and never flatten providers that publish many or frequently changing ranges by hand.

Better options, in order of preference:

  1. Move senders to subdomains. Send marketing from news.example.com and transactional mail from mail.example.com; each subdomain gets its own SPF record and its own 10-lookup budget, and relaxed DMARC alignment still works.
  2. Use a custom Return-Path at the vendor. Most ESPs let you set a bounce domain like bounce.example.com with a CNAME to them. SPF is then evaluated on that subdomain, and the vendor's include leaves your root record entirely.
  3. Rely on DKIM for vendors that cannot align SPF. DMARC only needs one aligned pass.

Step 3: DKIM Setup, Key Sizes and Rotation

DKIM record syntax

Each sending service signs with a private key and you publish the public key under a selector it gives you:

s2026a._domainkey.example.com.  3600  IN  TXT  ( "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
                                                "...remaining base64..." )

Many providers ask you to publish a CNAME instead (for example s1._domainkey.example.com CNAME s1.domainkey.u123.wl.sendgrid.net), which lets them rotate keys without you touching DNS again. Accept that option when it is offered.

If you run your own signer (Postfix with OpenDKIM, or your MTA's built-in DKIM), generate a key and the record value like this:

openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out dkim-s2026a.key
P=$(openssl pkey -in dkim-s2026a.key -pubout -outform DER | openssl base64 -A)
echo "v=DKIM1; k=rsa; p=$P"

A 2048-bit key produces a 392-character base64 string and a record of about 410 characters. A single DNS TXT string holds at most 255 characters, so the value must be split into two quoted strings, which most DNS consoles do for you and some do badly. Verify the published value by concatenating the strings from dig output, as the SPF script does.

Key size

RFC 8301 requires signers to use RSA keys of at least 1024 bits, says they "SHOULD use RSA keys of at least 2048 bits", and bans rsa-sha1 entirely. Google's sender guidelines require a key of 1024 bits or longer for mail to personal Gmail accounts and recommend 2048. Use 2048 everywhere your provider supports it. Keys longer than that gain little and run into the DNS size issues above.

Rotation

The M3AAWG DKIM Key Rotation Best Common Practices (revised March 2019) recommend rotating keys "at least every six months". Selectors make rotation safe:

  1. Publish the new selector (s2026b) alongside the old one.
  2. Wait for DNS caches to expire (longer than the record's TTL), then switch the signer to s2026b.
  3. Keep s2026a published for a few days so messages in transit and retries still verify.
  4. Remove the old record, or publish it with an empty p= to mark it revoked.

Date-based selector names make it obvious which key is current. For keys managed by your ESP through CNAMEs, confirm with them that they rotate.

Step 4: DMARC Record and Rollout From p=none to p=reject

DMARC record syntax

_dmarc.example.com.  3600  IN  TXT  "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com; adkim=r; aspf=r"
Tag Meaning
v=DMARC1 Required, must come first
p= Policy for failing mail: none, quarantine or reject
sp= Policy for existing subdomains, if different from p
np= Policy for non-existent subdomains (new in RFC 9989, imported from RFC 9091)
rua= Where to send daily aggregate (XML) reports
ruf= / fo= Per-message failure reports and their trigger options; optional, and they can contain message content
adkim= / aspf= Alignment mode, r (relaxed, default) or s (strict)
t= Test mode, new in RFC 9989: t=y asks receivers to apply one level below the stated policy

What changed in May 2026

The IETF published the updated DMARC specification in May 2026 as RFC 9989 (the protocol), RFC 9990 (aggregate reporting) and RFC 9991 (failure reporting), obsoleting RFC 7489. For domain owners the practical changes are:

  • pct, rf and ri are removed. pct (apply the policy to a percentage of mail) is replaced by the t flag. Existing records keep working because unknown tags are ignored, but do not build a new rollout around pct ramps.
  • np and psd tags are added, and the Public Suffix List lookup is replaced by a "DNS Tree Walk" for finding the organizational domain.
  • A missing p tag is treated as p=none in an otherwise valid record.

For example, Gmail's own record when I checked was v=DMARC1; p=none; sp=quarantine; rua=mailto:mailauth-reports@google.com, while GitHub's still carried the legacy pct=100 alongside p=quarantine; sp=reject.

A rollout schedule that does not lose mail

Phase Record Exit criteria
1. Monitor p=none; rua=... 2–4 weeks of reports; every legitimate source identified
2. Fix still p=none All legitimate sources pass DKIM (or SPF) with alignment
3. Quarantine, test p=quarantine; t=y Reports stay clean for 1–2 weeks
4. Quarantine p=quarantine No legitimate failures for 2–4 weeks
5. Reject p=reject Keep monitoring reports permanently

t=y is new, so not every receiver honors it yet; treat phase 3 as optional insurance rather than a guarantee. Add np=reject early, since nobody legitimately sends from subdomains that do not exist.

Aggregate reports are XML files, one per receiver per day. Volume grows quickly, so send them to a dedicated mailbox or a DMARC report-processing service. If rua points to a different domain, that domain must authorize it with a TXT record at example.com._report._dmarc.reportingdomain.net containing v=DMARC1, as described in RFC 9990; hosted report services publish this for you. The reports, plus everything in this guide, are also what email security platforms build their dashboards on.

Gmail, Yahoo and Microsoft Bulk Sender Requirements

As of December 2026, the three largest consumer mailbox providers publish these rules for high-volume senders:

Requirement Gmail Yahoo Outlook.com (Microsoft)
Who is a bulk sender 5,000+ messages/day to personal Gmail accounts Bulk senders (the best-practices page sets no fixed number) 5,000+ emails/day
SPF and DKIM Both Both SPF must pass, DKIM must pass
DMARC At least p=none At least p=none, and DMARC must pass At least p=none, aligned with SPF or DKIM
From: alignment With SPF or DKIM domain With SPF or DKIM domain With SPF or DKIM domain
One-click unsubscribe Required for marketing and subscribed mail (RFC 8058) Required; honor within 2 days Recommended (working unsubscribe link)
Spam complaint rate Below 0.30%, aim for below 0.10% Below 0.3% Not specified
Enforcement Since Feb 1, 2024; ramped up from November 2025 with temporary and permanent rejections Since February 2024 Rejections with 550; 5.7.515 since May 5, 2025

Sources: Google's email sender guidelines and FAQ, Yahoo Sender Hub best practices, and Microsoft's announcement for Outlook.com high-volume senders. Microsoft's post was updated on April 29, 2025 to say non-compliant messages would be rejected with "550; 5.7.515 Access denied, sending domain [SendingDomain] does not meet the required authentication level" rather than sent to Junk.

Two details worth knowing. Google counts volume per primary domain, so mail from example.com and news.example.com adds up, and its FAQ states that bulk sender status is permanent once reached. And all three providers also expect valid forward and reverse DNS (PTR) for sending IPs and RFC 5322-compliant messages. If you are choosing an ESP, check that it supports custom DKIM, a custom Return-Path and RFC 8058 headers; our comparison of email marketing platforms is a starting point.

How to Check SPF, DKIM and DMARC With dig

# SPF: should return exactly one v=spf1 record
dig +short TXT example.com | grep -i 'v=spf1'

# DKIM: the selector comes from your provider or the s= tag of a signed message
dig +short TXT s2026a._domainkey.example.com

# DMARC
dig +short TXT _dmarc.example.com

# External report authorization (only if rua points to another domain)
dig +short TXT example.com._report._dmarc.reports.example.net

DNS is only half the test. Send a message to a Gmail or Outlook mailbox you control, open the original headers and read the Authentication-Results header. You want all three to pass, with domains that match your From: address:

Authentication-Results: mx.google.com;
       dkim=pass header.i=@example.com header.s=s2026a header.b=AbCdEf12;
       spf=pass (google.com: domain of bounce@mail.example.com designates 198.51.100.25 as permitted sender) smtp.mailfrom=bounce@mail.example.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=example.com

Here DKIM passes for example.com (aligned), SPF passes for mail.example.com (aligned under relaxed mode), and DMARC passes. If DKIM shows the vendor's domain in header.i instead of yours, custom DKIM is not set up at that vendor yet.

Frequently Asked Questions

Do I need SPF, DKIM and DMARC if I only send a few emails?

Gmail requires SPF or DKIM from every sender and all three only from senders of 5,000+ messages a day, but unauthenticated mail is more likely to land in spam or be rejected at any volume. DMARC also stops others from spoofing your domain, which matters even if you send very little.

What happens if my SPF record has more than 10 lookups?

Receivers return a permerror for SPF, which DMARC treats as a failure. If DKIM is aligned and passing, DMARC can still pass, but you lose SPF as a backup. Reduce lookups by moving senders to subdomains or using custom Return-Path domains rather than flattening by hand.

How long should I stay at p=none?

Long enough to see every legitimate source in your aggregate reports and fix it, typically two to four weeks for a small organization and several months for large ones with many vendors. Staying at p=none forever gives you reports but no protection against spoofing.

Should I use 1024-bit or 2048-bit DKIM keys?

Use 2048-bit keys. RFC 8301 says signers should use at least 2048 bits, and Google recommends 2048 while accepting 1024 as the minimum. Only fall back to 1024 if your DNS provider cannot publish the longer record.

Is the DMARC pct tag still supported?

The pct tag was removed from the DMARC standard in RFC 9989 (May 2026) and replaced by the t test flag. Existing records containing pct remain valid because receivers ignore unknown tags, but new rollouts should use t=y and full policies instead of percentage ramps.

Conclusion

A solid SPF, DKIM and DMARC setup is mostly inventory and patience. Publish one SPF record under the 10-lookup limit, turn on 2048-bit DKIM at every sender and rotate keys twice a year, then walk DMARC from p=none to p=reject using aggregate reports as your evidence. Check the results with dig and real message headers, and you will meet Gmail, Yahoo and Microsoft's requirements while closing your domain to spoofers.