Email Landing in Spam for All Recipients – Fix

Server & Cloud Intermediate 👁 23 views 📅 Jun 28, 2026

Your email is hitting spam because of a missing or messed-up SPF record. Here's how to check and fix it on your DNS.

Quick answer: Run dig TXT yourdomain.com | grep v=spf1 on your server. If nothing comes back, your SPF record is missing — add one like v=spf1 mx include:_spf.google.com ~all (if using Google Workspace) in your DNS.

The real reason your email lands in spam for every recipient isn't black magic or bad luck. It's a broken DNS record. When you send an email, the receiving server checks three things: SPF (who can send from your domain), DKIM (a digital signature), and DMARC (what to do if checks fail). If SPF is missing or wrong, the receiving server thinks your email might be faked. Most big providers like Gmail, Outlook, and Yahoo then mark it as spam for everyone. The fix is simple, but it's very specific to your setup.

What's Actually Happening Here

Your mail server sends an email. The receiving server does a dig TXT yourdomain.com to see who's authorized. If that record is missing, or if it lists a different server than the one you're using, the check fails. Gmail's spam filter treats that as a big red flag. Even if your email is legit, it won't matter — the technical check says 'not authorized'. That's why all recipients, not just some, see it in spam.

Step-by-Step Fix

  1. Find your domain's DNS panel. Log in where you manage DNS — usually your domain registrar (GoDaddy, Namecheap) or your hosting provider (cPanel, Cloudflare). You need to edit TXT records.
  2. Check your current SPF record. Run dig TXT yourdomain.com on any Linux machine. If you're on Windows, use nslookup -type=TXT yourdomain.com. Look for something like v=spf1. If nothing shows up, that's your problem.
  3. Create the SPF record. In your DNS panel, add a new TXT record. The name is @ or blank (your root domain). For the value, you need to list what servers send your email. Common examples:
    • If you use Google Workspace: v=spf1 include:_spf.google.com ~all
    • If you use your own server (like Postfix on a VPS): v=spf1 mx ~all (this says your MX servers can send mail)
    • If you use a third-party sender like SendGrid: v=spf1 include:sendgrid.net ~all
    The ~all at the end means 'softfail' — it's safe for testing. For production, use -all (hard fail) after you're sure it works.
  4. Wait for DNS propagation. This usually takes 1–2 hours, sometimes up to 24. Check with dig TXT yourdomain.com again after a few hours.
  5. Test sending an email. Send a test email to a Gmail address. Open the original message (three dots > Show original). Look for spf=pass. If you see spf=fail or spf=neutral, something's wrong.

Alternative Fixes If SPF Doesn't Help

Sometimes SPF alone isn't enough. If you still get spam after adding the record, check these next:

  • DKIM signing. Most modern mail servers support DKIM. For Postfix with OpenDKIM, run opendkim-genkey -D /etc/opendkim/keys/ -d yourdomain.com -s default. Then add the resulting TXT record to your DNS. Gmail checks DKIM more than SPF these days.
  • DMARC policy. Add a DMARC record to tell receivers what to do when checks fail. A simple one: v=DMARC1; p=none; rua=mailto:admin@yourdomain.com. The p=none won't block anything, but it gives you reports to see who's failing.
  • Reverse DNS (PTR record). If your server's IP has no reverse DNS matching your domain, some providers (like Yahoo) penalize you. Ask your hosting provider to set the PTR record for your IP to mail.yourdomain.com.

Why This Works (The Nerd Details)

The receiving server's mail filter logs the SPF result. If it's missing, the filter assigns a negative score. Gmail's spam filter is a Bayesian system — it combines many signals (SPF, DKIM, header consistency, user complaints). A missing SPF gives a big negative weight. Adding it removes that penalty. The reason step 3 works is that the include: mechanism tells the receiver exactly which IPs are legit. Without it, the filter has no way to know.

Prevention Tip

Set up all three records (SPF, DKIM, DMARC) before you send any email from a new domain. Test with a free tool like MXToolbox's SPF checker. Update SPF every time you change mail providers. If you add a new service like Mailchimp, add their include to your existing SPF — never replace it entirely unless you're sure you removed old servers.

One more thing: don't use +all in your SPF. That allows anyone to send as you. I've seen people copy-paste wrong records from tutorials. Double-check every character.

Was this solution helpful?