Deliverability

Nodemailer DKIM Emails Going to Spam in Gmail: What to Fix

A valid DKIM signature only proves the message wasn't altered; it doesn't earn inbox placement. When Nodemailer verification emails land in Gmail spam, the usual causes are misaligned domains, missing SPF or DMARC, a new sending IP or domain, and link or content problems. Check the Authentication-Results header first.

Sohail HussainSohail Hussain10 min read

Short answer

  • A passing DKIM check does not guarantee inbox placement. Open a spammed copy in Gmail, choose Show original, and check SPF, DKIM and DMARC, and whether the DKIM domain matches your From domain.
  • If all three pass, the cause is usually sending-IP reputation, missing reverse DNS or TLS, or low-quality signups. Fix those, or relay through an established transactional provider while keeping your own DKIM signature.

Your Nodemailer account-verification emails are signed with DKIM, you are not routing them through SendGrid, and more than half still land in Gmail's spam folder. That is the situation behind this page. The original report is from 2020, but the causes have not changed much. Gmail's rules have only become stricter since then.

Why it happens

DKIM proves that a domain signed the message. It does not prove the message is wanted. Gmail looks at authentication, alignment, the reputation of your domain and IP, and what recipients do with your mail. Most common cause first:

  1. The DKIM domain does not align with the From domain. Google says that for direct mail the domain in the From: header must be aligned with either the SPF domain or the DKIM domain. A signature that passes for d=other.com while you send From you@example.com is valid but misaligned.
  2. SPF is missing or does not cover your sending server. Google notes that if third-party senders aren't included in your SPF record, messages are more likely to be marked as spam.
  3. No DMARC record. Gmail requires one only from bulk senders, but a p=none record is cheap and gives you reports.
  4. Reverse DNS or TLS is missing. Google's sender guidelines ask that sending domains or IPs have valid forward and reverse DNS records (PTR). A self-hosted VPS often fails this.
  5. A new or poorly reputed IP. Cloud IP ranges are shared with other tenants. Gmail has no history for a fresh domain either. Partial spam placement (some mail in the inbox, some not) is typical of this.
  6. Fake or mistyped signups. Verification mail sent to people who never asked for it gets reported, and that teaches Gmail to distrust the stream.
  7. A weak DKIM key. Sending to personal Gmail accounts requires a DKIM key of 1,024 bits or longer, and Google recommends 2,048 bits.

Step-by-step fixes

1. Read the headers on a spammed copy

  1. Send a verification email to a Gmail address you control.
  2. Open the copy in Spam, click the three-dot menu, and choose Show original.
  3. Read the SPF, DKIM and DMARC lines at the top. You can also paste the raw message into the email header analyzer.

A healthy result looks like this:

Authentication-Results: mx.google.com;
       dkim=pass header.i=@example.com header.s=mail;
       spf=pass smtp.mailfrom=bounce@example.com;
       dmarc=pass (p=NONE) header.from=example.com
What you seeLikely causeFix
dkim=pass, dmarc=failDKIM domain differs from From domain, SPF not aligned eitherFix alignment (step 2)
dkim=fail or neutralWrong key, wrong selector, or the message was altered after signingCheck DNS key and relay (step 2)
spf=none or spf=failNo SPF record, or sender IP not listedPublish SPF (step 3)
No DMARC resultNo DMARC recordPublish DMARC (step 4)
All passReputation, PTR, TLS or contentSteps 5 to 7

2. Align the DKIM domain and check the key

In Nodemailer, the d= value comes from domainName. Make it match the From domain or share its organizational domain.

const transporter = nodemailer.createTransport({
  host: 'smtp.example.com',
  port: 587,
  secure: false,
  auth: { user: 'smtp-user', pass: 'secret' },
  dkim: {
    domainName: 'example.com',
    keySelector: 'mail',
    privateKey: process.env.DKIM_PRIVATE_KEY,
  },
});

await transporter.sendMail({
  from: 'Example <no-reply@example.com>',
  to: user.email,
  subject: 'Verify your Example account',
  text: 'Your verification link: https://example.com/verify?token=...',
  html: '<p>Your verification link: <a href="https://example.com/verify?token=...">Verify</a></p>',
});

Google's AMP documentation gives a useful example of relaxed alignment: a signature verifying with d=foo.example.com aligns with foo@example.com, but user@gmail.com would not align. So never send From a Gmail or Outlook address while signing with your own domain; no code change fixes that.

Then confirm three things:

  1. The public key is a TXT record at mail._domainkey.example.com (selector, then _domainkey, then your domain).
  2. The private key in your environment is the pair of that public key. A mismatch gives dkim=fail.
  3. The key is 2048 bits if your DNS host accepts long TXT values. The DKIM generator makes a key pair and the record.

If you send through an SMTP relay that rewrites the body (adds a footer, rewrites links), the signature Nodemailer made can break. Turn that rewriting off, or let the relay sign instead.

3. Publish SPF for the path you actually use

example.com.  TXT  "v=spf1 ip4:203.0.113.10 include:_spf.your-relay.example ~all"

Use only the include your relay documents. Keep one SPF record per domain; two records cause a permanent error. Stay under the 10-lookup limit, which the SPF lookup count calculator checks, and let the SPF generator build the string. If you relay through a provider, SPF may pass for the provider's domain and not align with yours. That is acceptable, because only one of SPF or DKIM needs to be aligned. Google still recommends aligning both.

4. Add DMARC in monitoring mode

DNS TXT Record
Type:TXT
Host:_dmarc
Value:v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com

Google states that your DMARC enforcement policy can be set to none. Read the aggregate reports for a couple of weeks and fix anything unaligned before moving to quarantine. The DMARC generator and our SPF, DKIM and DMARC setup guide cover the details.

Do not skip alignment

A message that passes DKIM and SPF but aligns with neither can still fail DMARC. Check the dmarc line in the headers, not only the dkim and spf lines.

5. Fix reverse DNS and TLS if you send from your own server

If Nodemailer connects straight to Gmail's servers from a VPS, the sending IP needs a PTR record that resolves to a hostname, and that hostname must resolve back to the same IP. Set the PTR at your hosting provider, not your DNS host. Google's FAQ lists the error for a missing one: 5.7.25, blocked because the sending IP has no PTR record or the forward entry does not reference the IP. It also says Gmail requires bulk senders to use TLS for SMTP connections. Use STARTTLS on port 587 or implicit TLS on 465 in any case.

6. Reduce the reputation problem

  1. Check blocklists for your sending IP (see blacklist). A listed IP hurts even with perfect authentication.
  2. Register your domain in Google Postmaster Tools to see spam rate and authentication rates. Google warns that the dashboard might not include all data on days when outgoing email volume is low, so a small sender may see little.
  3. Keep complaints low. Google's target is a user-reported spam rate below 0.10%, and never reaching 0.30% or higher.
  4. Ramp up gradually. You cannot schedule signups, but you can avoid a sudden burst from a cold IP. See the domain warm-up guide.
  5. Use a separate subdomain such as mail.example.com for transactional mail, so promotional complaints do not drag verification mail down.

I'd use an established transactional provider (SES, Postmark, Mailgun, SendGrid and others) for anything you cannot afford to lose, such as signup verification. Nodemailer talks to any of them over SMTP. You can keep your own DKIM signing, as long as the provider does not alter the message afterward. Running your own mail server is the hardest route, because the IP starts with no history.

7. Clean up the message and the signup form

  • Send both text and html parts.
  • Put the verification link on your own https:// domain, not a shortener or an unrelated tracking host.
  • Keep it short: what it is, the link, an expiry time, and a line saying to ignore it if they did not sign up.
  • Use a subject with your product name, such as "Verify your Example account", and a From name users recognize.
  • Validate addresses at signup (syntax, MX, disposable domains) and add bot protection to the form, so you do not mail dead or unwilling recipients.
  • Do not add promotional copy or heavy images to a transactional message.

Unsubscribe headers

A one-off verification email does not need a List-Unsubscribe header. If the same system also sends marketing mail, the rules change; see our note on transactional versus marketing email.

Checklist before you try again

  • dkim=pass and domainName matches the From domain (or shares its organizational domain)
  • DKIM key is at least 1024 bits, ideally 2048
  • One SPF record that lists your real sending server
  • A DMARC record exists, even at p=none
  • PTR record and forward DNS match the sending IP
  • SMTP connection uses TLS
  • IP and domain are not on a blocklist
  • Message has plain text and HTML parts and an https:// link on your domain
  • Transactional mail is separated from marketing mail

How long changes take

DNS changes usually show up within minutes to a few hours, depending on TTL. Reputation moves slowly: expect days or weeks of clean, steady sending. Change one thing at a time and retest with a few Gmail addresses, reading the headers each time. The spam checker is a word-list scorer, useful for obvious wording problems but not a substitute for a real inbox test.

If nothing works

If every check passes, your IP is clean and volume is steady but most mail still goes to spam, the problem is reputation and no code change will fix it. Contact your relay provider's support (or your hosting provider, if you send from your own IP). Include the full headers of a spammed message, the sending IP, timestamps, and what you already tried. Google's sender guidelines are the reference to check current requirements.

Subject: Verification emails from {your-domain} landing in Gmail spam

Hello,

Transactional verification emails sent from {your-domain} (sending IP {ip-address})
are landing in the Gmail spam folder for a large share of recipients.

Authentication-Results from a spammed Gmail message (full headers attached):
dkim=pass, spf=pass, dmarc=pass (all aligned with the From domain)

Sent: {timestamp with timezone}
Message-ID: {message-id}
Already checked: SPF, DKIM key length 2048, DMARC p=none, PTR record, TLS,
blocklists, plain-text part present.

Can you review the reputation of this IP and domain with Gmail, and tell us
whether other customers on the same IP are affecting delivery?

Thanks,
{name}

Common questions

Is DKIM enough to stay out of Gmail spam?

No. Google says authenticated messages are less likely to be rejected or marked as spam by Gmail, which is a reduction in risk, not a guarantee. Alignment, reputation and recipient behavior still count.

Do I need DMARC if I send only a few verification emails a day?

Google requires it from bulk senders, which it defines as more than 5,000 messages daily. A p=none record is still worth adding, because it gives you reports and shows whether anything is unaligned.

Should I move to a transactional provider?

If you send from a fresh VPS IP, yes, in most cases. A provider's IPs already have sending history, and it handles bounces. You give up some control and pay a bill; keep your own DKIM selector so the signature stays on your domain.

Why did this start suddenly?

Check what changed: a new IP or domain, a DNS edit that broke SPF or DKIM, a rotated private key, or a spike in fake signups. Rereading the headers on a current spammed message shows which check changed.

deliverabilitynodemailergmail
Share this article
Sohail Hussain

Sohail Hussain

Founder & CEO at Mailneo

Building Mailneo — AI-powered email marketing for growing businesses.

Related Articles

Deliverability

421-4.7.0 Try again later, closing connection (EHLO): fix

The error "421-4.7.0 Try again later, closing connection. (EHLO)" means Google's SMTP server is temporarily refusing your session, usually because of connection volume, a low-reputation IP, or a weak relay setup. Slow down, reuse one connection, queue with retries, authenticate, and send a real EHLO hostname.

Sohail Hussain|11 min read
Deliverability

421-4.7.0 Gmail Has Detected This Message Is Suspicious: Fix

The 421-4.7.0 "suspicious due to the nature of the content and/or the links" error means Gmail's content filter rejected your message after DATA, not an authentication check. Remove click tracking or move it to your own domain, drop URL shorteners, check link reputation, then retest with a plain message.

Sohail Hussain|10 min read
Deliverability

421 4.7.0 Temporary System Problem. Try again later (10)

`421 4.7.0 Temporary System Problem. Try again later (10).` is a temporary Gmail deferral, not a permanent rejection. Google's server asked your sender to retry later. Slow your send rate, let your mail server retry, and check authentication and reputation if the deferrals last more than a day or two.

Sohail Hussain|9 min read
Deliverability

421 4.7.28 Gmail Unusual Rate of Unsolicited Mail: Fixes

The 421 4.7.28 error is a temporary Gmail deferral, not a block. Gmail is rate limiting a domain, DKIM domain or IP range it sees sending too much unwanted mail. Retries usually deliver, but you should fix authentication, unsubscribe headers, sending pace and shared infrastructure to stop it recurring.

Sohail Hussain|9 min read

Ready to supercharge your email marketing?

Start sending smarter emails with AI-powered campaigns. No credit card required.

Get Started Free