WordPress emails going to spam is a different problem from emails that never leave the server. The message was sent and accepted; the receiving service then decided it did not trust it. Gmail, Outlook and Yahoo make that decision mostly from three DNS records and from whether the domain in your From address matches the domains that passed those checks.
If your mail is not arriving at all, start with fixing WordPress emails that are not sending, which covers logging and an authenticated relay. This guide picks up after that: mail arrives, in the wrong folder. You need access to your domain’s DNS, the dashboard of your mail provider, and one message from the site that reached a Gmail inbox or spam folder.
From experience · Md. Zubaer Ahammed
On the WordPress sites I look after, mail that lands in spam is rarely WordPress’s fault. Very often SPF and DKIM both say “pass”, but for the mail provider’s domain and not for the site’s own. So I read the domains in Authentication-Results before I change any setting.
Read the verdict the receiver already wrote in the message headers
Every large mailbox provider records what it checked in a header called Authentication-Results. In Gmail, open the message, choose Show original from the three-dot menu, and look for it near the top. A message with a problem looks like this:
Authentication-Results: mx.google.com; dkim=pass header.i=@sendgrid.net header.s=s1; spf=pass smtp.mailfrom=bounces.sendgrid.net; dmarc=fail (p=NONE) header.from=example.com Read the domains, not only the words “pass” and “fail”. SPF passed for bounces.sendgrid.net, and DKIM passed for sendgrid.net. Both belong to the mail provider. The visible sender is example.com, and nothing that passed carries that domain, so DMARC failed. This is the most common reason a correctly sent WordPress email ends up in spam: the checks pass for somebody else’s domain.
If the raw headers are hard to read, paste them into the “Check a received message” box of this free email deliverability checker. It reads the SPF, DKIM and DMARC results out of the headers in your browser, and the message is not sent anywhere. The sections below fix each line in turn.
One SPF record, at most ten lookups, and an ending that means something
SPF is a TXT record that lists who may send mail for a domain. Three mistakes account for most SPF failures. Look at what your domain publishes first:
dig +short TXT example.com | grep -i 'v=spf1' If that prints two lines, you have two SPF records, and receivers treat that as an error and ignore both. It happens when a second service tells you to “add this SPF record” and you add it beside the first. Merge them into one record with one include per service:
v=spf1 include:_spf.google.com include:sendgrid.net ~all The second mistake is the lookup limit. A receiver may make at most ten DNS lookups while evaluating SPF, and every include, a, mx and redirect counts, including the ones nested inside each include. Go over ten and the result is an error, which most receivers treat like a failure. Remove services you no longer send through; that is nearly always enough.
The third is the ending. ~all marks other senders as suspicious, -all rejects them, and +all allows the whole internet to send as you and should never be used. Stay on ~all until DKIM is working, because forwarded mail can fail SPF through no fault of yours.
DKIM only helps when the signature carries your own domain
DKIM adds a cryptographic signature to each message. The receiver finds the public key in DNS and checks that the message was not altered. A provider will happily sign with its own domain by default, which is what header.i=@sendgrid.net showed in the example. That signature is valid, and it does nothing for your domain’s standing.
Every serious mail provider has a setting usually called domain authentication, a verified sending domain or a custom DKIM domain. It gives you two or three DNS records to add, after which messages are signed as d=example.com. The signature header names a selector in its s= field, and that selector tells you where the public key lives:
# selector "s1" taken from the s= field of the DKIM-Signature header dig +short TXT s1._domainkey.example.com dig +short CNAME s1._domainkey.example.com One of those two commands should return an answer: a TXT record holding the key, or a CNAME pointing at the provider’s key. If neither does, the DNS records from the provider’s setup page are missing or were added under the wrong name. A common slip is a DNS panel that appends the domain automatically, so that s1._domainkey.example.com typed in full becomes s1._domainkey.example.com.example.com.
DMARC alignment is the test Gmail and Yahoo now apply to everyone
DMARC ties the first two checks to the address your reader sees. It passes when SPF or DKIM passes and the domain that passed matches the domain in the From header. Matching is relaxed by default, so mail.example.com aligns with example.com. A pass for the provider’s domain does not align with yours, however valid it is.
Since February 2024, Gmail and Yahoo expect every sender to pass SPF or DKIM, and senders of around 5,000 or more messages a day to Gmail must pass both, publish a DMARC record, keep reported spam under 0.3% and offer one-click unsubscribe on marketing mail. A small WordPress site is far below that volume, but the same checks decide where its mail lands.
A sensible first DMARC record asks for reports and changes nothing about delivery:
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:dmarc@example.com" p=none tells receivers to take no action on failures. rua is the address that receives daily summary reports, which show every service sending as your domain and whether each one aligns. To see all three records for your domain on one screen, enter the domain in the same SPF, DKIM and DMARC checker; add the DKIM selector to have it look up the key as well. It reads public DNS only. It does not count SPF lookups, send a test message or judge your reputation, so the headers of a real message remain the final proof.
The WordPress side: the From address and the Return-Path must be your domain
DNS can be perfect and WordPress can still undo it. Left alone, wp_mail() sends from wordpress@ followed by the site’s host name, and the envelope sender, which SPF checks, is often the server’s own name. Set both to a real mailbox on the domain you authenticated. A small must-use plugin does it for every message:
<?php /** * Plugin Name: WP Tuts Hub – consistent mail sender * File: wp-content/mu-plugins/wp-tuts-hub-mail-sender.php */ add_filter( 'wp_mail_from', function () { return 'hello@example.com'; } ); add_filter( 'wp_mail_from_name', function () { return 'Example Shop'; } ); // Make the envelope sender (Return-Path) match the From address. add_action( 'phpmailer_init', function ( $phpmailer ) { $phpmailer->Sender = $phpmailer->From; } ); The two filters fix the visible sender. The phpmailer_init action sets PHPMailer’s Sender property, which becomes the Return-Path, so the domain SPF evaluates is yours too. If you send through a relay that uses its own bounce address, leave that last block out and rely on DKIM for alignment, which is the reason the custom DKIM domain matters so much.
Two plugin habits break this. Contact form plugins are often configured to send “from” the visitor’s address, which can never align with your domain: keep your own address in From and put the visitor in Reply-To. WooCommerce has its own “From” address under its email settings, and it should be the same mailbox.
Everything passes and mail still lands in spam
Passing all three checks does not guarantee the inbox. When the headers show three passes with your own domain and the message is still filtered, the cause is reputation or content.
- A shared or new sending address. Mail sent straight from a shared host leaves from an address used by hundreds of other sites, and their behaviour counts against you. A transactional mail provider gives you a cleaner starting point.
- A new domain. A domain registered last week with no sending history is treated with caution. Volume that grows gradually builds a record.
- Complaints. People who mark your mail as spam teach the filter quickly. Send only what users asked for, and make unsubscribing easy.
- Content. Link shorteners, a message that is one large image, and links whose text shows one address while pointing at another all look like phishing.
- Mixing mail types. Send newsletters from a subdomain such as
news.example.comso a bad campaign cannot damage password resets and order receipts.
Google’s free Postmaster Tools shows how Gmail rates your domain and the share of your mail that users report as spam. For Gmail, it is the only place to see that figure directly.
My tip · Md. Zubaer Ahammed
After every DNS change, send one test message to a Gmail address and open Show original. Gmail lists SPF, DKIM and DMARC at the top with pass or fail beside each. Keep the earlier message open in another tab, so you can compare before and after.
Watch the DMARC reports for two weeks before you tighten the policy
Once the headers show your domain passing, leave p=none in place and read the reports that arrive at the rua address. They are XML files, and several free services turn them into readable tables. You are looking for sources you forgot: an invoicing service, a booking system, an old newsletter account still sending as your domain.
When every legitimate source aligns, change the policy to p=quarantine, and later to p=reject. From then on, anyone forging your domain is filtered out, and receivers have a clear reason to trust what remains.
Official reference: Google’s email sender guidelines list the current requirements, and the Code Reference documents the wp_mail_from filter and the phpmailer_init action used above.
Originally published on WP Tuts Hub.
