<!-- SPF, DKIM and DMARC setup | install: npx skills add prosyo-ai/gtm-skill --skill email-authentication-setup | source: https://github.com/prosyo-ai/gtm-skill/tree/main/skills/email-authentication-setup -->

---
name: email-authentication-setup
description: "Use this skill when you need to set up or fix SPF, DKIM and DMARC for a sending domain: \"set up SPF DKIM DMARC\", \"my DMARC is failing\", \"write my SPF record\", \"meet bulk sender requirements\". Inventories every service that sends as the domain, writes the exact DNS records, explains alignment, plans a safe DMARC rollout from monitoring to enforcement, and gives the checks that confirm everything passes."
license: MIT
metadata:
  title: SPF, DKIM and DMARC setup
  category: deliverability
  tags: "RevOps, Founders, Agencies"
  author: prosyo
  version: "1.0.0"
  keywords: "spf dkim dmarc setup, how to set up dmarc, spf record generator, claude email authentication skill, bulk sender requirements"
  inputs: "Domain, Services that send email as the domain, Current DNS records"
  outputs: "Sender inventory, Exact DNS records, DMARC rollout plan, Verification checklist"
---

Use this when a domain sends email and authentication is missing, broken or failing alignment. Without all three records passing, major mailbox providers junk or reject bulk and cold mail.

## Inputs

- The domain.
- Every service that sends email as that domain: mailbox provider, marketing platform, CRM, support desk, billing, product notifications.
- Current DNS records, if any.

## The play

### 1. Inventory senders
List every service and how it sends: does it send "as" your domain, and does it support custom DKIM? Missing a sender here is how a DMARC rollout ends up blocking invoices.

### 2. SPF
One TXT record on the domain listing every service, ending in `~all` (soft fail) or `-all` (hard fail).

```
v=spf1 include:<mail provider> include:<marketing service> ~all
```

Rules: exactly one SPF record per domain; 10 DNS lookups or fewer (each `include` counts, and nested includes count too). Over 10 lookups causes a permanent error and SPF fails for everyone. Use subdomains for high-volume services to stay under the limit.

### 3. DKIM
Turn on signing in each service and publish the key it gives you (usually a CNAME or TXT at `<selector>._domainkey.<domain>`). Then confirm signing is actually enabled; a published key with signing off is a common silent failure.

### 4. DMARC
Start in monitoring mode and tighten over weeks:

| Stage | Record | When to move on |
| --- | --- | --- |
| Monitor | `v=DMARC1; p=none; rua=mailto:<reports address you own>` | 2-4 weeks of reports show all legitimate senders passing |
| Quarantine | `p=quarantine; pct=25` then 50, 100 | No legitimate mail failing |
| Reject | `p=reject` | Optional, for maximum protection |

Read [references/dns-records.md](references/dns-records.md) for record examples, alignment explained and how to read aggregate reports.

### 5. Verify
Send test emails to a mailbox you control and check the headers: `spf=pass`, `dkim=pass`, `dmarc=pass`, with the From domain aligned.

## What good looks like

- Every legitimate sender passes DMARC before the policy moves past `p=none`.
- SPF stays under 10 lookups with room to add a service.
- DMARC reports go to an address the user owns and someone actually reads them.
- The common mistake is publishing `p=reject` on day one and silently blocking the billing system's emails.

## Rules

- MUST inventory all senders before changing SPF or DMARC.
- MUST start DMARC at `p=none`.
- MUST send DMARC reports only to addresses or services the user controls.
- NEVER publish a second SPF record; merge into one.
- NEVER change DNS without the user's explicit approval.

## Example prompts

- "Write SPF, DKIM and DMARC for acme.com. We send from our mailbox provider, a marketing platform and a support desk."
- "Our DMARC report shows failures from an IP we don't recognise. What is it?"
- "We're over the SPF lookup limit. Fix it."


---

<!-- references/dns-records.md -->

# DNS records and alignment

## Record examples

| Record | Host | Type | Example value |
| --- | --- | --- | --- |
| SPF | `@` (the domain) | TXT | `v=spf1 include:_spf.mailprovider.example include:send.marketing.example ~all` |
| DKIM | `s1._domainkey` | CNAME or TXT | Value given by the sending service |
| DMARC (monitor) | `_dmarc` | TXT | `v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com; fo=1` |
| DMARC (enforce) | `_dmarc` | TXT | `v=DMARC1; p=quarantine; pct=100; rua=mailto:dmarc@yourdomain.com` |

Host names and include values above are placeholders; use the exact values each service documents.

## Alignment in plain words

DMARC passes when at least one of these is true:

- **SPF aligned**: the message passes SPF and the envelope sender domain (Return-Path) matches the visible From domain.
- **DKIM aligned**: the message has a valid DKIM signature whose `d=` domain matches the visible From domain.

Many services send with their own Return-Path, so SPF alignment fails even though SPF passes. That is why custom DKIM for each service matters most: it is usually the route to alignment.

Relaxed alignment (the default) accepts subdomains: `news.yourdomain.com` aligns with `yourdomain.com`.

## SPF lookup counting

Each of these costs one lookup: `include`, `a`, `mx`, `ptr`, `exists`, `redirect`. Nested includes inside an include also count. `ip4` and `ip6` cost nothing.

Ways to stay under 10:
- Move a high-volume service to a subdomain with its own SPF.
- Remove services you no longer use.
- Replace an include with its `ip4` ranges only if the service publishes stable ranges (otherwise this breaks when they change).

## Reading aggregate (rua) reports

Group rows by source IP and sending service:

| Source | Volume | SPF aligned | DKIM aligned | Verdict |
| --- | --- | --- | --- | --- |
| Mailbox provider | 12,400 | yes | yes | Good |
| Marketing platform | 8,100 | no | yes | Good (DKIM carries it) |
| Support desk | 640 | no | no | Fix: enable custom DKIM |
| Unknown IP range | 90 | no | no | Investigate: possible spoofing or a forgotten service |

Move to quarantine only when every legitimate source is aligned.
