spf-dkim-dmarc-setup
Skill1 starsChanged 2 months agoMITView on GitHub
Configure and debug SPF, DKIM and DMARC DNS records for a sending domain. Use whenever the user mentions SPF, DKIM, DMARC, BIMI, email authentication, DNS records for email, "emails failing authentication", dmarc reports, p=none or p=quarantine or p=reject, SPF lookup limit, or is setting up a new sending domain. Also use when mail is being rejected or junked and the cause is unclear.
In this repository30 other files it gives its agents.
- agency-multi-client-outboundSkill
- bounce-recoverySkill
- catch-all-risky-emailsSkill
- cold-email-copywritingSkill
- crm-data-hygieneSkill
- ecommerce-store-prospectingSkill
- email-deliverabilitySkill
- email-sequence-designSkill
- email-verificationSkill
- email-warmupSkill
- funding-news-signalsSkill
- google-maps-lead-scrapingSkill
- icp-definitionSkill
- inbox-rotation-scalingSkill
- job-posting-signalsSkill
- lead-enrichmentSkill
- lead-scoring-qualificationSkill
- lead-sourcingSkill
- linkedin-prospectingSkill
- meeting-booking-ctaSkill
- outbound-campaign-opsSkill
- outbound-complianceSkill
- outbound-metrics-benchmarksSkill
- personalization-at-scaleSkill
- reply-handlingSkill
- spam-filter-triggersSkill
- subject-line-optimizationSkill
- suppression-list-managementSkill
- technographic-signalsSkill
- web-scraping-lead-dataSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 101
Which sources are sending as my domain?: Every one should be recognised.
- Very specific: line 104
What share passes?: Should reach 98%+ before moving to reject.
- Very specific: line 117
Over the lookup limit?: Look for permerror.
- Very specific: line 121
Subdomain policy: If sending from mail.example.com, check sp= on the parent.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SPF, DKIM and DMARC
Three DNS records that tell receiving servers your mail is genuinely yours. Without all three, a significant share of your email is filtered before any content check happens — and since Google and Yahoo tightened bulk sender requirements, authentication is a prerequisite rather than an optimisation.
Set them up before sending anything. Debugging them after a domain has been damaged is much slower.
SPF
A TXT record on the domain listing who may send for it.
v=spf1 include:_spf.google.com include:sendgrid.net ~all| Part | Meaning |
v=spf1 | Version. Always first |
include: | Delegate to a provider's own SPF record |
ip4: / ip6: | Authorise a specific address or range |
~all | Soft fail — anything else is suspicious |
-all | Hard fail — anything else is forged |
?all | Neutral. Pointless, don't use |
The rules that break in practice:
- One SPF record per domain. Two TXT records both starting
v=spf1is a permanent fail, and it silently breaks all your mail. It happens when a second provider is added by someone who doesn't know a record already exists. Merge the includes into one record. - Ten DNS lookup limit. Each
include:costs at least one lookup and nested includes count too. Exceed ten and the result ispermerror, which most receivers treat as a fail. Big providers' includes are expensive; four or five is often enough to hit the ceiling. ~allover-allwhile getting started. Move to-allonce DMARC reports confirm nothing legitimate is failing.- SPF breaks on forwarding. A forwarded message keeps the original sender but arrives from a new IP. This is why DKIM matters and why DMARC accepts either.
# Check it exists and there's exactly one
dig +short TXT yourdomain.com | grep -c 'v=spf1' # must be 1
# Count lookups (rough — includes nest)
dig +short TXT yourdomain.com | grep -o 'include:' | wc -lDKIM
A cryptographic signature. The provider signs outgoing mail with a private key; you publish the public key in DNS at a selector.
google._domainkey.yourdomain.com TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSq..."
^selectorThe selector varies by provider — google, s1, k1, selector1 and selector2 for Microsoft, and so on. Your provider tells you which and gives you the record; you publish it.
Practical notes:
- 2048-bit keys where the provider supports it. Some DNS hosts require splitting the value across strings for long records.
- Each sending service needs its own selector. Google Workspace, a transactional provider and a marketing tool are three separate DKIM records, and all three can coexist.
- Turn on signing after publishing the key. Signing with a key that isn't in DNS yet fails everything.
- Rotate periodically by publishing a new selector, switching, then removing the old one.
dig +short TXT google._domainkey.yourdomain.com
dig +short TXT selector1._domainkey.yourdomain.comDMARC
Ties the other two together. It tells receivers what to do when authentication fails, and it's the only one that sends you reports.
_dmarc.yourdomain.com TXT "v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com; fo=1; adkim=r; aspf=r"| Tag | Meaning |
p= | Policy: none, quarantine, reject |
rua= | Where aggregate reports go |
ruf= | Forensic reports. Often unsupported, and they contain message data |
pct= | Percentage of mail the policy applies to. Useful for phased rollout |
adkim= / aspf= | Alignment: r relaxed (subdomains match), s strict |
sp= | Policy for subdomains |
Roll it out in stages. Never start at reject.
Week 1-2 p=none Monitor only. Read the reports.
Week 3-4 p=quarantine; pct=10 Small share to junk
Week 5-6 p=quarantine All failures to junk
Week 7+ p=reject Failures rejected outrightThe point of p=none is the reports. They reveal every service sending as your domain — the CRM, the invoicing tool, the helpdesk, the thing marketing set up in 2019 — and there is always at least one nobody remembered. Going straight to reject deletes that mail with no warning.
DMARC passes if either SPF or DKIM passes and aligns with the From domain. Alignment is the part people miss: SPF can pass for the envelope sender while failing alignment because the From header shows a different domain.
Reading DMARC reports
Aggregate reports arrive as gzipped XML, daily, from every major receiver. They're unreadable by hand at volume — use a parser or a monitoring service — but the questions are simple:
- Which sources are sending as my domain? Every one should be recognised.
- Which are failing? Legitimate ones need fixing before you tighten the policy.
- Is anything unrecognised passing? That's a serious finding.
- What share passes? Should reach 98%+ before moving to
reject.
# Rough look at a single report
gunzip -c report.xml.gz | grep -oE '<source_ip>[^<]+|<disposition>[^<]+|<dkim>[^<]+|<spf>[^<]+'Debugging a failure
In order:
- Send to a seed address and read the raw headers.
Authentication-Resultsstates plainly which of the three passed. - Two SPF records? Most common single cause.
- Over the lookup limit? Look for
permerror. - DKIM selector published and signing enabled? Both, not one.
- Alignment. Does the From domain match what SPF and DKIM authenticated?
- DNS propagated? New records take time; a low TTL before changes helps.
- Subdomain policy. If sending from
mail.example.com, checksp=on the parent.
Authentication-Results: mx.google.com;
dkim=pass header.i=@yourdomain.com;
spf=pass smtp.mailfrom=yourdomain.com;
dmarc=pass (p=NONE) header.from=yourdomain.comThree passes is the target. Anything else is the finding.
Bulk sender requirements
Google and Yahoo now require, for anyone sending meaningful volume to their users:
- SPF and DKIM both configured
- A DMARC policy published, at minimum
p=none - Alignment between the From domain and the authenticated domain
- One-click unsubscribe headers on bulk mail (
List-UnsubscribeandList-Unsubscribe-Post) - Spam complaint rate kept under 0.3%, and ideally under 0.1%
These are enforced. Failing them means filtering rather than a warning.
BIMI
Publishes your logo next to authenticated mail in supporting clients. It requires p=quarantine or p=reject first, plus an SVG Tiny PS logo, and for most inbox providers a Verified Mark Certificate, which costs real money annually.
Worth it for consumer brands with high volume. Not worth it for cold outbound, where you're sending from lookalike domains anyway.
Don't do these
- Don't publish two SPF records. Merge them.
- Don't start DMARC at
p=reject. You'll silently kill mail you forgot about. - Don't use
ruf=casually — forensic reports can contain message content and most receivers ignore the tag anyway. - Don't authenticate the primary domain and forget the outbound ones. Each sending domain needs its own full set.
- Don't assume the provider did it. Most set up DKIM and leave SPF and DMARC to you.
- Don't set
-allbefore the reports are clean.
Related skills
email-deliverability, email-warmup, spam-filter-triggers, bounce-recovery, inbox-rotation-scaling
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

