Skip to content
New: Laravel Hosting, Node.js Hosting & GitHub DeploysSee the plans →
Products
Solutions
Developers

Guides

Fix email that Gmail rejects or marks as spam

Why Gmail bounces or junks mail from your domain, the two DNS records that fix it, and how to prove they are working in two minutes.

Introduction

If Gmail bounces mail from your domain with an authentication error, or accepts it and places it in spam, Gmail usually cannot prove the message came from your domain. Since 2024, Google and Yahoo have required every sending domain to authenticate its mail. This guide covers the DNS records involved, how to check them, and how to fix them.

SPF and DKIM

SPF is a list, published in your DNS, of the servers allowed to send mail for your domain. When a message arrives, Gmail checks whether the server that delivered it is on the list. SPF is one TXT record on the root of your domain:

v=spf1 a mx ~all

This record allows the servers that your domain’s website and mail records point at. On our platform that is correct, because your mail is sent from the server that hosts your site.

DKIM is a signature. Your mail server signs every outgoing message with a private key and publishes the matching public key in your DNS, so Gmail can verify the signature. The key lives at a subdomain called a selector. Our selector is hostingcp, so the record is located at:

hostingcp._domainkey.yourdomain.com

SPF confirms that the server may send for your domain, and DKIM confirms that the message was not altered in transit. Gmail requires both.

Checking Authentication

Send an email from your domain to a Gmail address you control. Open it in Gmail, click the three dots, then Show original. The top of the page shows the result:

SPF:   PASS
DKIM:  PASS
DMARC: PASS

If SPF or DKIM shows FAIL or SOFTFAIL, continue to the fixes below.

If all three show PASS, authentication is not the problem. Spam placement with passing authentication is usually caused by content or reputation, such as a link that blocklists flag, a burst of identical messages, or a new domain with no history. Increase your sending volume gradually to build a history.

Fixing Authentication

Litehost Nameservers

If your domain uses our nameservers, both records are created automatically when your mailbox is set up. A failure usually means the domain was migrated from another host and the old records came with it. Open the DNS editor in the panel and check the following:

  1. More than one TXT record starting with v=spf1. Receivers treat multiple SPF records as an automatic failure. Delete the old host’s record and keep ours.
  2. A missing hostingcp._domainkey record. Open a ticket and we will enable signing for the domain, which takes a few minutes.

External DNS

If your domain’s DNS is at Cloudflare or your registrar and only the website points at us, our panel cannot publish these records for you. The records exist on our side, but other mail servers cannot see them.

Copy both records into the DNS you use: the SPF TXT record on the root, and the DKIM key from the panel’s email authentication page onto hostingcp._domainkey.

If you use Cloudflare, TXT records cannot be proxied, so they copy over as they are. Your MX record must stay unproxied (grey cloud, not orange) and keep pointing at your mail hostname. With the website proxied, that MX entry is what makes the SPF check pass, so check it first if mail stops when you enable Cloudflare.

Adding DMARC

DMARC is a policy record that tells receivers what to do when SPF or DKIM fails, and Gmail expects to find one. Once SPF and DKIM pass, add a DMARC record in monitoring mode:

_dmarc.yourdomain.com   TXT   "v=DMARC1; p=none"

The p=none policy does not affect delivery. Once real mail has been passing for a few weeks, you may change it to p=quarantine.

Confirming the Fix

DNS changes may take up to an hour to be seen everywhere. After that, repeat the Show original test. Once all three lines show PASS, the fix is complete and needs no renewal or maintenance.

Warning: Do not pay for a mail warmup service or resend a failed campaign. Reputation recovers on its own once authentication passes, and a sudden burst of mail slows that recovery.

Keep reading

Other guides

Start building today

Laravel apps with queues and Horizon, WordPress stores, Node.js servers. One container with SSH, deploys from GitHub and people who answer. One bill a year.

Launch my site