← All posts

Emails Landing in Spam? How to Set Up SPF, DKIM and DMARC for Your Domain (Complete Guide)

Quotes that never arrive, lost contact forms, invoices in junk folders: how to properly authenticate your domain's email with SPF, DKIM and DMARC, including messages sent by your website.

Emails Landing in Spam? How to Set Up SPF, DKIM and DMARC for Your Domain (Complete Guide)

Key points

  • Since 2024, Gmail and Yahoo require authenticated email: a domain without SPF or DKIM gets its messages filtered or rejected.
  • SPF lists the servers allowed to send, DKIM signs every message, DMARC says what to do on failure and sends you reports.
  • The most common trap: the website, newsletter tool or CRM sends on behalf of the domain without being declared.

“Your quote never arrived.” When a client tells us that, the instinct is to blame the recipient. In practice, in the vast majority of cases we handle, the problem is on the sender’s side: the domain isn’t properly authenticated, or only partly. The outcome is insidious because nothing warns you. Messages go out, no bounce comes back, and they end up in junk folders or vanish entirely. This guide explains, without needless jargon but with the exact records to publish, how to check and fix your domain’s setup: SPF, DKIM, DMARC, and the special case of email sent by your WordPress site.

Why your emails end up in spam (and what changed)

Technically, an email is a bit like a letter where anyone can write any return address on the back. Nothing in the original protocol stops an arbitrary server from sending a message “from” hello@your-domain.com, which is exactly what phishing relies on. To sort the genuine from the fake, mailbox providers check three mechanisms published in your domain’s DNS:

  • SPF: the list of servers allowed to send for your domain;
  • DKIM: a cryptographic signature added to every message, which the recipient checks against a public key published in your DNS;
  • DMARC: the policy that ties both to the address the recipient actually sees, says what to do on failure and lets you receive reports.

For years these were recommended rather than required. Not anymore. Since February 2024, Google and Yahoo require every message to pass at least SPF or DKIM, and high-volume senders to Gmail (Google sets the threshold at 5,000 messages a day) must have SPF, DKIM and DMARC, plus one-click unsubscribe for marketing email. Microsoft announced comparable requirements for Outlook.com in 2025. In practice, a domain that worked “well enough” two years ago can now see its mail filtered without anyone touching a thing.

Warning signs: clients saying they never got a quote or invoice, WooCommerce order notifications nobody can find, contact-form replies landing in your own junk folder, or newsletter open rates collapsing overnight. Authentication isn’t the only deliverability factor (content, reputation and complaints matter too), but it’s the foundation: without it, nothing else helps.

Step 1: list everything that sends email on your behalf

This is the step almost everyone skips, and it causes most of the failures. Before touching DNS, list every tool that sends messages using an address on your domain. On our projects the list usually includes:

  • your main mailbox provider (Google Workspace, Microsoft 365, your host’s mail service);
  • the website: contact forms, customer accounts, WooCommerce notifications, password resets;
  • the newsletter or email marketing tool;
  • the CRM, invoicing or quoting software, the helpdesk;
  • sometimes a scanner or a line-of-business app that emails PDFs.

For each one, note which server it sends through and which sender address it uses. Serious tools have an “authenticate your domain” page that gives you the records to publish: follow that page rather than a generic tutorial. If a tool offers no domain authentication at all, it’s better to have it send from an address on its own domain than on yours.

Our advice when there are many tools: dedicate a subdomain to automated or marketing email (for example news.your-domain.com). Each subdomain has its own SPF and DKIM records, and if a campaign triggers complaints, the reputation of your main domain, the one you use to talk to clients, is protected.

Step 2: publish a correct SPF record

SPF is a TXT record at the root of the domain that starts with v=spf1. It lists authorised servers, either through include: mechanisms pointing at a provider’s list, or as IP addresses:

; A single SPF TXT record at the root of the domain
example.com.   3600  IN  TXT  "v=spf1 include:_spf.google.com include:spf.service-newsletter.example ip4:203.0.113.25 ~all"

; For Microsoft 365, the include would be:
;   include:spf.protection.outlook.com

The ending matters: ~all (soft fail) means other servers aren’t authorised but the message shouldn’t be rejected on that basis alone; -all asks for rejection. With DMARC in place, ~all is the safe choice for most domains. Never use +all, which authorises the entire internet.

Three mistakes come up again and again in our audits:

  • Two SPF records. Every new tool says to “add an SPF record”, and you end up with several. The standard only allows one: with two, SPF is invalid for the whole domain.
  • Too many DNS lookups. SPF is capped at 10 DNS lookups (each include, a or mx costs at least one, and includes can nest more). Beyond that, the result is an error. Remove services you no longer use and move marketing email to a subdomain.
  • Forgetting the web server. If your site sends directly from its hosting, that server’s IP must be in SPF, or better, the site should go through an authenticated service (see below).
; DON'T: two SPF records = invalid SPF (permerror)
example.com.  TXT  "v=spf1 include:_spf.google.com ~all"
example.com.  TXT  "v=spf1 include:spf.service-newsletter.example ~all"

; Correct: one record merging both
example.com.  TXT  "v=spf1 include:_spf.google.com include:spf.service-newsletter.example ~all"

One detail that catches people out: SPF checks the envelope address (the technical “Return-Path”), not necessarily the one the recipient sees. Many services use their own envelope domain, so your SPF can be perfect and still irrelevant for those messages. That’s why DKIM matters.

Step 3: turn on DKIM for every service

DKIM is the sturdiest mechanism: the sending server signs each message with a private key, and the matching public key is published in your DNS under a name like selector._domainkey.your-domain.com. The selector lets you have several keys, one per service.

; DKIM published as a CNAME (the service handles key rotation)
s1._domainkey.example.com.   CNAME  s1.dkim.service-newsletter.example.

; DKIM published as TXT (key supplied by your mailbox provider, 2048 bits)
google._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqh...IDAQAB"

Unlike SPF, DKIM isn’t a single record: each service has its own, with its own selector, so there’s no conflict. The steps are always the same: generate or fetch the key in the service’s admin, publish the record it gives you, wait for propagation, then click “verify” or “start authentication” in the service. That last step is often forgotten: in Google Workspace, for instance, a key published in DNS does nothing until signing is started in the admin console.

A few things to watch:

  • prefer 2048-bit keys when your DNS host accepts long records; some control panels truncate the value, and signing then fails with no clear message;
  • when a service offers a CNAME instead of a TXT record, take the CNAME: it lets the service rotate keys for you;
  • paste the value without stray quotes or spaces: that’s the number one cause of “published but failing” DKIM we fix.

Step 4: roll out DMARC gradually

DMARC does two things. First, it checks alignment: passing SPF or DKIM isn’t enough, the validated domain must match the one in the visible From address. A message DKIM-signed with your newsletter provider’s domain instead of yours doesn’t count. Second, it tells receivers what to do with failing messages and asks them to send you reports.

; Step 1: observe without blocking anything
_dmarc.example.com.  TXT  "v=DMARC1; p=none; rua=mailto:dmarc@example.com; fo=1"

; Step 2 (after several weeks of clean reports): quarantine
_dmarc.example.com.  TXT  "v=DMARC1; p=quarantine; pct=25; rua=mailto:dmarc@example.com"

; Step 3: reject unauthenticated messages
_dmarc.example.com.  TXT  "v=DMARC1; p=reject; rua=mailto:dmarc@example.com"

Never start straight at p=reject: if a legitimate tool was missed in the inventory, its messages would be rejected. The approach we use:

  • publish p=none with a rua address that receives aggregate reports;
  • read the reports for a few weeks: they’re XML files, unreadable as-is, but plenty of tools (free and paid) turn them into per-source tables;
  • fix each legitimate source that fails (missing DKIM, wrong sender domain);
  • move to p=quarantine, optionally on a share of traffic with pct, then to p=reject once nothing legitimate fails any more.

Create a dedicated mailbox for reports rather than sending them to someone’s inbox: on an active domain they arrive daily. And if the rua address is on another domain, that domain must publish a specific authorisation record, or the reports simply won’t be sent.

Should you go all the way to p=reject? For a domain that sends invoices or payment requests, yes: it’s the best protection against spoofing. For a small domain with a single tool, quarantine is already a clear improvement. The real mistake is sitting on p=none forever without ever reading the reports.

The WordPress case: why form submissions go missing

By default, WordPress sends email with PHP’s mail() function, straight from the hosting server. That server usually isn’t listed in SPF, doesn’t DKIM-sign with your domain, and sometimes shares its IP with other sites whose reputation isn’t yours. That’s why form and order notifications are so often the first to disappear.

The reliable fix is to route the site through a real authenticated SMTP server: your mailbox provider’s, or a transactional email service whose domain authentication you’ve completed (DKIM included). We covered plugin-free SMTP setup in a separate article. Combine it with one simple rule about the sender:

<?php
// mu-plugins/sender.php: every email from the site is sent from an address on the domain
add_filter( 'wp_mail_from', fn() => 'site@example.com' );
add_filter( 'wp_mail_from_name', fn() => 'Example Ltd' );

// The visitor who filled in the form goes in Reply-To, never in From
add_filter( 'wp_mail', function ( $args ) {
    if ( ! empty( $_POST['email'] ) && is_email( wp_unslash( $_POST['email'] ) ) ) {
        $args['headers']   = (array) $args['headers']; // may be a string
        $args['headers'][] = 'Reply-To: ' . sanitize_email( wp_unslash( $_POST['email'] ) );
    }
    return $args;
} );

This is crucial and very often misconfigured in form plugins: if the From field holds the visitor’s address (jane@gmail.com), your server is sending a message “from” Gmail without permission. Gmail’s DMARC policy fails it and the message gets filtered, sometimes in your own inbox. The visitor’s address belongs in Reply-To: you hit Reply and you’re writing to them.

If the site runs on a dedicated server or VPS that sends its own mail, add two checks: the IP needs a reverse DNS (PTR) record matching a sensible hostname, and it mustn’t appear on public blocklists. Either way, using a specialist service is usually simpler than maintaining a sending server’s reputation yourself.

Verifying the result and keeping an eye on it

Once the records are published, don’t trust your registrar’s control panel: check what DNS actually serves. From the command line:

# What DNS actually serves (not what you think you typed)
dig +short TXT example.com | grep spf1
dig +short TXT _dmarc.example.com
dig +short TXT google._domainkey.example.com
dig +short CNAME s1._domainkey.example.com

# Does the server sending from your hosting have a consistent reverse DNS?
dig +short -x 203.0.113.25

The most telling test is a real send. Send a message from each tool on your list to a Gmail address, open it, then use “Show original”: Gmail displays an SPF / DKIM / DMARC table with each result. In the raw headers, the line to read is this one:

Authentication-Results: mx.google.com;
       dkim=pass header.i=@example.com header.s=google;
       spf=pass (google.com: domain of contact@example.com designates 203.0.113.25 as permitted sender) smtp.mailfrom=contact@example.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=example.com

All three should say pass, and the DKIM domain (header.i or header.d) should be yours, not the provider’s. Repeat for the website form, an order notification, a newsletter and an invoice: it’s often the fourth tool, the forgotten one, that fails.

Finally, authentication isn’t a one-off setting. Every new tool, every change of provider or mailbox service means updating the inventory, removing the old include and enabling the new DKIM. DMARC reports are your alarm: a new failing source shows up there before clients tell you they’ve stopped receiving anything. If messages still land in spam despite correct authentication, look next at reputation (Google Postmaster Tools for Gmail), content (image-only emails, URL shorteners, executable attachments) and the quality of your mailing list.

FAQ

How long do DNS changes take to apply?

It depends on the records’ cache lifetime (TTL): often a few minutes to a few hours. Check with dig rather than waiting blindly, and avoid changing several things at once so you know which fix worked.

SPF and DKIM are set up, so why does DMARC still fail?

Almost always an alignment issue: the message passes SPF or DKIM, but with the provider’s domain rather than yours. Turn on domain authentication in that tool so it signs with your domain.

Can switching DMARC to p=reject block my own emails?

Yes, those from any legitimate tool that isn’t properly authenticated. That’s why you go through an observation phase at p=none, reading the reports, before tightening the policy step by step.

My host says “everything is configured”. How can I check myself?

Send an email to a Gmail address from each of your tools and open “Show original”: you’ll see the SPF, DKIM and DMARC result for every send straight away, without reading any DNS.

Emails that don’t arrive, a website form that lands in spam, a mailbox migration to plan? We audit your domain setup, fix SPF, DKIM and DMARC, and make your website’s email reliable.

Share LinkedIn Facebook X WhatsApp
</>

webtestudio

Web agency: custom WordPress sites, premium themes and SaaS software.

Discuss your project →