
How to set up SPF, DKIM and DMARC to improve email deliverability
A step-by-step guide to publishing SPF, DKIM and DMARC records for your domain. It covers a safe rollout from monitoring to enforcement, and how to check that each record works.
Illustration: UtiBox
On this page 7 sections
By the end of this guide you will have SPF, DKIM and DMARC records published for your domain, and a safe way to tighten them over time. These three DNS-based checks let receiving mail servers confirm that a message really comes from you. Without them, legitimate mail is more likely to land in spam or be rejected, and anyone can more easily forge your domain.
You need access to your domain's DNS settings and a list of every service that sends email as your domain. That usually means your mailbox provider, a newsletter tool, a helpdesk, a billing system and your website's contact forms.
Before you start: list your senders
- Write down every system that sends mail using your domain in the From address.
- For each one, find its documentation for SPF and DKIM setup. Each provider publishes its own values.
- Decide which address should receive DMARC reports. A mailbox you will actually read, or a reporting service, works well.
- Look at your current records with the DNS Lookup tool so you do not overwrite anything that already exists.
Step 1: publish an SPF record
SPF is a TXT record on your domain that lists the servers allowed to send mail for it.
- Check whether your domain already has an SPF record. A domain should have only one, so edit it rather than adding a second.
- Start the record with the version tag, then add one entry for each sender, using the include value each provider gives you.
- End the record with an instruction for everything not listed. Many people begin with a softer setting while testing, then move to a stricter one once they trust the list.
- Save the record and wait for DNS to update.
Watch the lookup limit. According to MxToolbox (opens in a new tab), quoting RFC 7208, an SPF check may use at most 10 DNS lookups, and that count includes include and redirect. Go over it and the check fails. Remove senders you no longer use, and avoid piling up includes.
Step 2: set up DKIM signing
DKIM adds a cryptographic signature to each message. The receiver checks that signature against a public key you publish in DNS.
- In each sending service, find the option to enable DKIM for your domain. The service generates the key pair and tells you what to publish.
- Note the selector name. According to RFC 6376 (opens in a new tab), the key is published as a DNS record under the selector, then the label _domainkey, then your domain.
- Add the record exactly as given. Some providers ask for a TXT record, others for a CNAME pointing to a record they host.
- Return to the service and run its verify or activate step so it begins signing.
- Repeat for every sender. Each can use its own selector, so they do not clash.
Long keys can be awkward. Some DNS panels need a long value split into several quoted strings, so follow your DNS host's guidance if a record is rejected.
Step 3: publish DMARC in monitoring mode
DMARC tells receivers what to do when a message fails authentication, and where to send reports. It builds on SPF and DKIM. RFC 7489 (opens in a new tab) defines three policies: none, quarantine and reject.
- Create a TXT record at _dmarc on your domain.
- Begin with the policy none, which asks receivers to take no action on failures but still lets reports flow.
- Add a rua tag with a mailto address for aggregate reports. The RFC's own example is a record with version DMARC1, policy none and a rua mailto address.
- Publish it, then wait a couple of weeks while reports arrive.
Step 4: read reports and fix gaps
- Look through the aggregate reports for sources sending as your domain.
- For each legitimate source that fails, fix its SPF or DKIM setup. Mail passes DMARC when it is aligned, meaning the domain checked matches the domain in the visible From address.
- Investigate unknown sources. They may be forgotten services, or they may be spoofing.
- Repeat until your real mail passes consistently.
Step 5: move toward enforcement
- Change the policy from none to quarantine, so failing mail is treated as suspicious, usually meaning spam folders.
- Keep watching reports for a while, and fix anything that breaks.
- When you are confident, move to reject, which asks receivers to refuse failing mail.
- Keep the records up to date when you add or retire a sending service.
Bulk senders face extra pressure. Vendor summaries note that Gmail and Yahoo expect SPF, DKIM and DMARC from high-volume senders, so check the current rules in Google's and Yahoo's own sender guidelines if you send newsletters at scale.
Check your work
- Run your domain through the SPF & DMARC Checker to confirm both records exist and are valid.
- Use the DNS Propagation Checker if a new record does not show up yet.
- Send a test message to an outside mailbox, open the original headers and look for pass results for SPF, DKIM and DMARC.
- Confirm you have only one SPF record and that it stays within 10 lookups.
- Confirm that DMARC reports are arriving at the address you chose.
Sources: IETF RFC 7489, DMARC (opens in a new tab), IETF RFC 6376, DKIM (opens in a new tab), MxToolbox (opens in a new tab)
Related
More from Guides
Redirect chains and loops: how to find them and cut them to one hop
Years of site moves leave redirect chains behind: http to https, bare domain to www, old page to new. Here’s how to trace every hop, fix loops and long chains, and choose the right status code for…
Link preview looks wrong? Fix your Open Graph tags step by step
Your link shows the wrong picture, an old headline or no card at all when it’s shared. Here’s how to see what social and chat apps read from your page, fix the tags and get the new preview to show.
How to compare two versions of a text, config file or code, and read the diff
“What changed?” is hard to answer by eye. Here’s how a diff works, when to compare line by line or word by word, and how to read the results in the Diff Checker and Text Compare.













