Home
Email Deliverability

SPF, DKIM, and DMARC: A Practical Setup Guide

SPF and DKIM checks converging on DMARC alignment for a visible From domain

SPF, DKIM, and DMARC at a glance

The three checks work as a chain, but they are not interchangeable. SPF follows the return path, DKIM follows a signed domain, and DMARC connects either result to what the recipient sees. Passing DMARC improves trust in the From domain, but it does not guarantee inbox placement or prove that a message is safe.

ProtocolChecksDNS locationDMARC needs
SPFAuthorised sending host for the envelope senderThe MAIL FROM domainPassing SPF identity aligned with visible From:
DKIMCryptographic signature for the signing domain<selector>._domainkey.example.comPassing DKIM identity aligned with visible From:
DMARCAt least one passing SPF or DKIM identity aligned with visible From:_dmarc.example.comOne aligned authentication pass

How does DMARC alignment decide pass or fail?

DMARC passes when SPF or DKIM passes and its domain aligns with visible From. Default relaxed alignment accepts a shared organisational domain; strict alignment requires an exact match. Aligned DKIM can preserve DMARC when forwarding breaks SPF.

SPF and DKIM results converging on DMARC alignment with the visible From domain

ResultSPFDKIMDMARC
Aligned SPF pathPass and alignedAny resultPass
Aligned DKIM pathAny resultPass and alignedPass
Authentication without alignmentPass but not alignedPass but not alignedFail
Neither method passesFailFailFail

How to configure SPF

Publish one SPF TXT record for each domain used in MAIL FROM. Start with v=spf1, add only the IP addresses and services that send for that domain, then finish with an all qualifier. Do not publish multiple SPF records at the same name. If a provider gives you an include value, treat it as part of that domain's lookup budget rather than copying a guessed record.

v=spf1 ip4:198.51.100.0/24 include:_spf.example.net -all

Keep SPF within the DNS lookup limit

SPF permits at most 10 DNS-querying terms, including nested terms. This covers include, a, mx, ptr, exists and redirect. More than 10 returns permerror. Count them before adding a sender, or move unrelated traffic to a return-path subdomain.

  • Use the ip4 and ip6 mechanisms only for address ranges the provider documents and keeps current.
  • Remove senders that no longer use the domain.
  • Give a separate return-path subdomain its own SPF record when the mail architecture calls for it.
  • Avoid static SPF flattening unless you also own a reliable process for tracking provider IP changes.

How to configure DKIM

DKIM signs selected headers and the body with a private key. The selector in DKIM-Signature tells receivers where to find the public key. RSA keys must be at least 1024 bits; 2048 bits is recommended. Providers may use CNAME records for rotation.

  1. Generate or request a DKIM key for the sending service.
  1. Publish the provider's TXT or CNAME record exactly, using the supplied selector.
  1. Enable signing with your domain in the d= tag.
  1. Send a real test message and confirm dkim=pass in Authentication-Results.
  1. During rotation, publish the new selector before switching the signer, then retire the old key after the transition.

How to configure DMARC

Publish DMARC at _dmarc.example.com. Begin with a monitoring policy and an aggregate-report destination you can actually process. The example below uses relaxed alignment. A receiver can send XML aggregate reports to the rua address, so use a dedicated mailbox or a trusted report processor and check whether external report destinations require additional authorisation.

v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com; aspf=r; adkim=r

How to roll out DMARC safely in 2026

RFC 9989 removed the old pct tag because receivers applied percentage sampling inconsistently. Do not use pct=10 or pct=50 as a staged rollout. For a domain with human users, mailing lists, or other varied senders, the current standard recommends monitoring at p=none for at least one month before p=reject, then spending an equally long period at p=quarantine. The t=y tag can signal that a policy is in testing, but receivers decide how to use it.

DMARC rollout from monitoring through quarantine to reject, with validation between stages

  1. Inventory every service that can send with the domain in its visible From address.
  1. Publish SPF and DKIM for each legitimate path, then test alignment on received messages.
  1. Publish p=none with rua, then review aggregate reports for at least one month.
  1. Correct unknown sources, broken selectors, SPF errors, and unaligned third-party signatures.
  1. Keep p=quarantine for the same representative period, then use p=reject only after valid mail consistently passes.

Where the DNS records belong

RecordExample owner nameTypical value
SPFexample.com or a return-path subdomainv=spf1 ... -all
DKIMselector1._domainkey.example.comv=DKIM1; k=rsa; p=... or a provider CNAME
DMARC_dmarc.example.comv=DMARC1; p=none; rua=mailto:...

How to test SPF, DKIM, and DMARC

Check DNS first, then inspect a message that travelled through the real sending path. DNS confirms the records are reachable; the received Authentication-Results header confirms whether the receiver evaluated them as expected. Test each provider and each From domain, because one successful path says nothing about a different sender or selector.

dig TXT example.com
dig TXT selector1._domainkey.example.com
dig TXT _dmarc.example.com
Authentication-Results: mx.example;
  spf=pass smtp.mailfrom=bounce.example.com;
  dkim=pass header.d=example.com header.s=selector1;
  dmarc=pass header.from=example.com

Common authentication failures

Most failures become straightforward once you separate authentication from alignment. Read the exact SPF result, DKIM result, selector, signing domain, envelope sender, and visible From domain before changing DNS. A record checker can prove that a value exists, but only a delivered message proves that the intended system used it.

SymptomLikely causeFix at the source
SPF permerrorMore than 10 lookup-producing termsRemove stale senders or redesign the return path
SPF fails after forwardingForwarder IP is not authorised by the original envelope domainRely on a valid aligned DKIM path where possible
dkim=fail with no keySelector in the signature does not resolvePublish the exact selector record used by the signer
DKIM passes but DMARC failsThe d= domain does not align with visible FromConfigure custom DKIM for the From domain
SPF passes but DMARC failsThe MAIL FROM domain does not align with visible FromConfigure an aligned custom return path

What Gmail, Yahoo, and Outlook require

Mailbox providers add operating rules to SPF, DKIM, and DMARC. The thresholds below apply alongside each provider's current unsubscribe and spam-rate controls for marketing or subscribed mail.

ProviderBaselineHigher-volume scopeHigher-volume authentication
GmailSPF or DKIM for all sendersMore than 5,000 messages per day to Gmail accountsSPF, DKIM, DMARC, and alignment
YahooSPF or DKIM for all sendersBulk sendersSPF, DKIM, DMARC, and alignment
Outlook.comNot stated hereMore than 5,000 messages per day to consumer addressesSPF, DKIM, and DMARC

How Sendmux handles domain authentication

Sendmux provides domain verification for managed sending domains. Its API returns the exact ownership, SPF, DKIM, DMARC, and MAIL FROM records a tenant must publish, then reports verification state for those checks. Sendmux can manage Amazon SES DKIM signing for the domain, but it is not a DMARC aggregate-reporting service, and custom SMTP, Gmail, or Outlook providers can require their own records.

  • Publish the records returned by the active sending provider as is, without making any changes to them.
  • Trigger verification when DNS is ready; Sendmux also rechecks unverified domains every six hours.
  • Overlay any provider-specific records required for bring-your-own sending accounts.
  • Re-test real messages after changing a sender, selector, or return path.

Deployment checklist

  1. List every visible From domain, return-path domain, sender, and selector.
  1. Confirm there is one valid SPF record per envelope domain and no more than 10 lookup-producing terms.
  1. Confirm each sender applies a valid DKIM signature using an aligned domain.
  1. Publish DMARC at p=none with working aggregate reporting.
  1. Test DNS and Authentication-Results for every production sending path.
  1. Monitor a representative period before moving to quarantine and then reject.
  1. Re-run the checks whenever a new provider or sending domain is added.

Sources

Protocol details come from current standards; provider thresholds come from operating guidance. Recheck both before writing policy because provider rules can change without an RFC change.

Frequently Asked Questions

What is the primary purpose of SPF, DKIM, and DMARC, and how do they work together?

SPF, DKIM, and DMARC are email authentication protocols that work in a chain to verify the legitimacy of email senders. SPF checks the sending server's IP address against a list of authorized senders, DKIM uses a cryptographic signature to ensure the message hasn't been tampered with, and DMARC ties these results to the visible 'From' domain, allowing the recipient's server to decide how to handle unauthenticated messages. Passing DMARC improves trust in the 'From' domain.

What is DMARC alignment, and why is it important?

DMARC alignment determines whether an email passes DMARC. It requires that either the SPF-verified domain or the DKIM-signed domain matches the visible 'From' domain in the email. Default relaxed alignment accepts a shared organizational domain, while strict alignment requires an exact match. Aligned DKIM is particularly important as it can preserve DMARC pass status even if forwarding breaks SPF.

How do I configure SPF, and what are common pitfalls to avoid?

To configure SPF, publish one SPF TXT record for each domain used in 'MAIL FROM'. Start with 'v=spf1', include only authorized IP addresses and services, and end with an 'all' qualifier (e.g., '-all' for hard fail). Avoid publishing multiple SPF records for the same domain and be mindful of the 10 DNS lookup limit, which can cause 'permerror' if exceeded.

How do I configure DKIM, and what should I look out for?

DKIM involves signing email headers and the body with a private key. You'll need to generate or request a DKIM key from your sending service and publish the provided TXT or CNAME record exactly, including the selector. Ensure RSA keys are at least 1024 bits (2048 bits recommended). After configuration, send a test message and confirm 'dkim=pass' in the 'Authentication-Results' header.

What is the recommended approach for rolling out DMARC safely?

Begin by publishing a DMARC record with a 'p=none' policy and a 'rua' address for aggregate reports. Monitor these reports for at least one month to identify legitimate sending sources and correct any issues. After a stable monitoring period, move to 'p=quarantine' for an equally long period, and only transition to 'p=reject' once valid mail consistently passes authentication and alignment checks.

How can I test my SPF, DKIM, and DMARC configurations?

First, use DNS lookup tools (e.g., `dig TXT example.com`) to confirm your records are published correctly. Then, inspect the 'Authentication-Results' header of a delivered email that has traveled through your real sending path. This header will show whether the recipient's server evaluated SPF, DKIM, and DMARC as expected. Test each provider and 'From' domain separately.

What are some common reasons for authentication failures, and how can they be fixed?

Common failures include SPF 'permerror' due to too many lookups (fix by removing stale senders or redesigning the return path), SPF failing after forwarding (rely on aligned DKIM), 'dkim=fail' with no key (publish the correct selector record), and DMARC failing despite SPF or DKIM passing (often due to the 'MAIL FROM' or DKIM 'd=' domain not aligning with the visible 'From' domain, requiring custom configuration for alignment).