মেনু

ক্যাটাগরি

PDF Tools Image Tools Audio Tools Video Tools Calculator Tools Developer Tools Text Tools SEO Tools Converter Tools More Tools

ভাষা

English Español Français Deutsch हिन्दी বাংলা

Email Authentication Deep Dive: SPF, DKIM, DMARC, and MX Setup to Stop Spoofing and Fix Deliverability

If transactional password resets, invoices, or outreach emails are landing in spam—or attackers are sending phishing emails pretending to come from your domain—the root cause almost always lives in four DNS and mail-transport layers: MX, SPF, DKIM, and DMARC.

Major inbox providers including Google Workspace/Gmail, Microsoft 365/Outlook, and Yahoo Mail strictly enforce email authentication for bulk and domain senders. Guessing DNS TXT strings or copying mismatched templates creates silent permerror failures that tank deliverability overnight. Here is how each protocol works, how they connect, and how to debug them cleanly.

How MX, SPF, DKIM, and DMARC Work Together

Each record defends a different piece of mail routing and identity:

  • MX (Mail Exchanger): Tells the internet which mail servers receive incoming email for your domain, ordered by priority integer (lowest number = highest priority).
  • SPF (Sender Policy Framework — RFC 7208): A DNS TXT record listing which IP addresses and third-party services are authorized to send mail claiming your domain in the SMTP MAIL FROM (Return-Path) envelope.
  • DKIM (DomainKeys Identified Mail — RFC 6376): A cryptographic signature added to email headers (DKIM-Signature:) by the sending server, verified against a public key published at <selector>._domainkey.yourdomain.com. Proves the message was not tampered with in transit and truly originated from someone holding the private key.
  • DMARC (Domain-based Message Authentication, Reporting, and Conformance — RFC 7489): A policy record at _dmarc.yourdomain.com that ties SPF and DKIM together via alignment with the visible From: header users actually see—and tells receiving servers whether to monitor (none), quarantine (quarantine), or reject (reject) spoofed mail.

Step 1: Verify MX Routing and Live SMTP Transport

Even though outbound authentication centers on SPF, DKIM, and DMARC, broken MX or SMTP configurations degrade domain reputation and bounce receipts.

Check your domain with MX Record Checker and SMTP Test:

  • Confirm MX hosts point to real hostnames (A/AAAA records), never to a CNAME or raw IP address (prohibited by RFC 5321).
  • Verify the receiving server greets cleanly (220), answers EHLO, and advertises STARTTLS with a valid TLS certificate so inbound mail encrypts in transit.
  • If your domain does not receive email at all (for example, a parked or marketing-only lookalike domain), publish a "null MX" record (0 .) alongside a strict v=spf1 -all and p=reject DMARC record so attackers cannot hijack it.

Step 2: Configure SPF Without Breaking the 10-Lookup Limit

An SPF record lives as a TXT record at your root domain (@ / apex). Every domain must publish at most one v=spf1 TXT record—publishing two separate v=spf1 records causes an immediate permerror failure across receivers!

A clean baseline SPF record looks like this:

v=spf1 include:_spf.google.com include:sendgrid.net ~all

The Fatal SPF Traps That Break Deliverability

  1. Exceeding the 10-DNS-lookup limit (RFC 7208 Section 4.6.4): Each include:, a, mx, ptr, exists, and redirect= mechanism triggers a DNS lookup—including nested include: chains inside your email vendors! Once evaluation hits lookup #11, receivers return PermError and fail SPF completely. Keep lookups lean (ideally 6 or fewer) and never use ptr (explicitly deprecated by RFC 7208).
  2. Using +all: Writing +all literally authorizes every IP address on the entire internet to spoof your domain.
  3. ~all (SoftFail) vs. -all (HardFail): When paired with an enforced DMARC policy (p=quarantine or p=reject), both ~all and -all prevent unauthorized mail from passing SPF. Many deliverability engineers prefer ~all during active DMARC rollout so mailing-list forwarders don't drop legitimate mail before DKIM alignment evaluates cleanly, while -all expresses strict rejection when every legitimate sender is verified.
  4. Publishing multiple SPF records: Always merge new senders into the single existing v=spf1 ... string rather than adding a second TXT row in your DNS panel.

Inspect what public resolvers actually see right now using SPF Checker.

Step 3: Deploy 2048-Bit DKIM Keys and Rotate Selectors

SPF breaks easily whenever emails get forwarded (because the forwarding server's IP isn't in your SPF record, changing the envelope Return-Path). DKIM survives forwarding as long as the signed headers and message body stay intact.

Your mail provider (Google Workspace, Microsoft 365, Postmark, Amazon SES, SendGrid, Mailgun) generates a keypair and asks you to publish the public key under a specific selector:

selector1._domainkey.yourdomain.com  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A..."

Key hygiene rules for 2026:

  • Use 2048-bit RSA keys (or Ed25519 where supported): Avoid legacy 1024-bit keys where your provider lets you upgrade; shorter keys are increasingly flagged as weak cryptographic posture.
  • Check DNS provider character limits: A 2048-bit DKIM TXT value exceeds 255 characters. Properly formatted DNS zones split long TXT strings into adjacent quoted 255-byte chunks inside a single record—modern providers like Cloudflare handle this automatically, whereas older registrar panels sometimes silently truncate keys.
  • Keep old selectors briefly when rotating: Publish the new selector (e.g., s2._domainkey), switch signing in your ESP, wait 48 hours for DNS TTLs and queued mail to drain, and then retire the old selector.

Verify your selector's TXT record directly with DKIM Checker.

Step 4: Enforce DMARC Safely (none -> quarantine -> reject)

Publishing SPF and DKIM alone does not prevent a phisher from spoofing your visible From: ceo@yourdomain.com header! An attacker can pass SPF using their own envelope domain (bounce@evil-phish.com) while displaying your domain in the From: line unless DMARC enforces Identifier Alignment.

DMARC requires at least one of SPF or DKIM to both pass AND align with the organizational domain in the visible From: header.

Safe 3-Stage DMARC Rollout

Never jump straight to p=reject on day one if multiple departments send mail through CRM, ticketing, billing, or newsletter tools you haven't inventoried yet.

Stage 1 — Monitor (p=none): Collect aggregate XML reports (rua) without blocking any mail:

_dmarc.yourdomain.com  TXT  "v=DMARC1; p=none; rua=mailto:dmarc-reports@yourdomain.com; fo=1"

(Publish at _dmarc.yourdomain.com using strictly v=DMARC1; at the start.)

Stage 2 — Quarantine (p=quarantine): Once 2–4 weeks of aggregate reports confirm every legitimate sender (billing, helpdesk, web app, workspace email) passes DKIM or aligned SPF, move suspicious unaligned mail to spam:

v=DMARC1; p=quarantine; pct=100; rua=mailto:dmarc-reports@yourdomain.com; adkim=r; aspf=r

Stage 3 — Reject (p=reject): Instruct compliant receivers to drop unauthenticated domain spoofing at the SMTP door:

v=DMARC1; p=reject; pct=100; rua=mailto:dmarc-reports@yourdomain.com; sp=reject; adkim=r; aspf=r

Notice sp=reject—this explicitly protects unused subdomains (like mail2.yourdomain.com or support.yourdomain.com) from being spoofed by phishers! Test your live _dmarc record right now with DMARC Checker.

Step 5: Inspect Real Headers and Check Sending IP Reputation

When an authenticated email still hits spam or bounces, inspect the raw Authentication-Results: header from a test message sent to a personal inbox using Email Header Analyzer:

  • Look for spf=pass, dkim=pass, and dmarc=pass.
  • If spf=pass but dmarc=fail, check alignment: your ESP's envelope smtp.mailfrom domain doesn't match your header.from domain, and DKIM isn't signing with your custom domain! Configuring a custom return-path CNAME and custom DKIM domain fixes alignment immediately.
  • If you send from a dedicated VPS or mail server IP, verify your IP hasn't landed on a DNSBL blocklist via IP Blacklist Checker, and ensure your reverse DNS (PTR) matches your mail server's HELO/EHLO hostname.

For broader DNS cutover and certificate debugging, keep our DNS, TLS, and Network Troubleshooting Runbook bookmarked.

Frequently Asked Questions

Can I have two DMARC records for one domain?

No. Like SPF, a domain may only publish one TXT record at _dmarc.yourdomain.com. Multiple _dmarc records cause receivers to ignore DMARC evaluation entirely.

Why did SPF fail when a contact forwarded my email?

Traditional email forwarding changes the connecting server IP and often keeps the original Return-Path, causing SPF to evaluate the forwarder's IP against your SPF record and fail. As long as your outbound email carries a valid DKIM signature matching your From: domain, DMARC still passes!

How long do DNS updates for SPF, DKIM, or DMARC take to apply?

New records usually appear on public resolvers within seconds to minutes, while changes to existing records depend on the record's previous TTL (Time To Live)—typically 5 minutes to 24 hours. Verify live resolution across resolvers with DNS Checker.

Audit Your Domain's Email Posture Now

Run every check in this guide from your browser in two minutes:

Try a free tool

Every tool runs in your browser with no account required.

Browse all tools