DNS & Email

SPF, DKIM and DMARC: Protect Your Domain from Phishing

Complete guide to configuring the three email authentication records. Protect your domain against spoofing and phishing attacks with step-by-step instructions.

2026-08-03·Reading time: 11 min

The SMTP protocol, the foundation of email since 1982, has no native authentication mechanism. Any mail server in the world can send a message claiming to be from '@yourdomain.com'. Without proper DNS records, it is impossible to distinguish it from a legitimate one. SPF, DKIM and DMARC are the three DNS records that solve this problem, and they are required by Gmail, Outlook and Yahoo to ensure email delivery.

SPF: Define Which Servers Can Send on Your Behalf

The SPF (Sender Policy Framework) record is a TXT record in your DNS that lists the servers authorized to send email from your domain. When a destination server receives a message from @yourdomain.com, it queries DNS to verify whether the sender is authorized. If not, the message may be marked as spam or rejected.

dns
; SPF record example for Google Workspace + SendGrid
yourdomain.com. IN TXT "v=spf1 mx include:_spf.google.com include:sendgrid.net ~all"

; Breakdown:
; mx                       → authorizes the domain's own MX servers
; include:_spf.google.com  → authorizes Google Workspace
; include:sendgrid.net     → authorizes SendGrid for transactional mail
; ~all                     → softfail: suspicious but not rejected
; -all                     → hardfail: rejected directly (stricter)

DKIM: Digital Signature of Every Sent Email

DKIM (DomainKeys Identified Mail) adds a cryptographic signature to every outgoing email using a private key stored on the server. The destination server verifies that signature with the public key published in your DNS. A valid DKIM email guarantees it was not altered in transit. Your email provider (Google Workspace, Microsoft 365, SendGrid) generates the key pair and gives you the TXT record to add to your DNS.

dns
; DKIM record example (Google Workspace)
; The selector ("google" here) is provided by your email provider
google._domainkey.yourdomain.com. IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBA..."

DMARC: The Policy Connecting SPF and DKIM

DMARC (Domain-based Message Authentication, Reporting & Conformance) defines what to do with emails that fail SPF or DKIM verification, and requests daily reports from email providers so you can monitor your domain usage.

dns
; DMARC record — start with p=none to monitor without rejecting
_dmarc.yourdomain.com. IN TXT "v=DMARC1; p=none; rua=mailto:[email protected]; pct=100"

; Recommended policy phases:
; p=none        → monitoring only, no rejections (phase 1)
; p=quarantine  → failing emails go to spam (phase 2)
; p=reject      → failing emails are rejected permanently (phase 3)

Step-by-Step Implementation

  • Step 1 — SPF: identify every service that sends email on your behalf (CRM, newsletter platform, billing system, own server) and add them to the SPF record.
  • Step 2 — DKIM: enable DKIM in your primary email provider and publish the public key in your DNS.
  • Step 3 — DMARC with p=none: add the DMARC record with monitoring-only policy and enable reports.
  • Step 4 — Analysis: review reports for 2-4 weeks to identify legitimate services not passing authentication.
  • Step 5 — Enforcement: when confident all legitimate senders pass SPF and DKIM, switch to p=quarantine and then p=reject.

Common Mistakes

  • More than one SPF record for the same domain: the standard only allows one. Merge all includes into a single TXT record.
  • More than 10 DNS lookups in SPF (too many lookups): the limit is 10. Exceeding it invalidates SPF entirely.
  • DMARC without active SPF and DKIM: DMARC alone has no effect without the other two mechanisms.
  • Going directly to p=reject without monitoring: you risk blocking legitimate emails from services not yet in SPF.

DomainScored verifies SPF, DKIM and DMARC in the DNS module and detects if any is missing, if SPF exceeds the lookup limit, or if the DMARC policy is too permissive. The report includes the exact content of each record and recommended fixes.

Check whether your domain has these issues with DomainScored.

Analyze my domain
We use necessary cookies to keep you signed in and protect you against CSRF attacks. If you accept, we will also load Google advertising, which sets its own cookies. If you decline, the site works exactly the same.