Salesforce Emails Going to Spam? Set Up SPF, DKIM and DMARC

Salesforce sends as your domain only after the domain vouches for it. The DNS records and Setup pages to fix, in order, with a command to check each one.

By Published

When Salesforce sends an email from your address, the receiving server asks your domain whether Salesforce is allowed to. If the domain has no answer, the message is delivered to spam, and Salesforce still shows it as sent. Four things have to be in place, and each one can be checked in a minute.

The steps are written for a domain on Google Workspace, and they are the same on Microsoft 365 apart from the Google records. You need a Salesforce admin and whoever can edit DNS for the domain.

Find out which system sent the email

One domain usually has several senders, and each one needs its own entry in SPF and its own DKIM key. Before changing anything, find out which system sent the message that went to spam. Salesforce keeps a record of every email it sends from a record or a flow.

SenderWhat it sendsSPF entryDKIM
Google WorkspaceEmail your people write in Gmailinclude:_spf.google.comA TXT record from the Google Admin console
SalesforceFlows, auto-replies, alerts, email sent from a recordinclude:_spf.salesforce.comA DKIM key made in Setup, published as two CNAME records
A marketing or receipts toolCampaigns, receipts, password resetsThe include that tool gives youThe records that tool gives you

Email that a user sends through their connected Gmail account, as in an Einstein Activity Capture setup, leaves through Google and is signed by Google. The rest of this page is about the email Salesforce sends itself.

Check what is published today

Run these from any terminal, with your domain and your selectors in place of the examples. They read public DNS and change nothing.

Terminal
# SPF: one record, and it names Salesforcedig +short TXT example.com # DMARCdig +short TXT _dmarc.example.com # Salesforce DKIM: both selectorsdig +short CNAME sf2026._domainkey.example.comdig +short CNAME sf2026a._domainkey.example.com

A domain that is set up correctly answers like this:

Expected output
"v=spf1 include:_spf.google.com include:_spf.salesforce.com ~all""v=DMARC1; p=none; rua=mailto:dmarc@example.com"sf2026.abc123.custdkim.salesforce.com.sf2026a.def456.custdkim.salesforce.com.

An empty answer on any line is the gap to close. The steps below take them in the order that causes the least risk to mail already flowing.

Step 1: Add Salesforce to your SPF record

SPF is one TXT record on the domain that lists who may send for it. Open the record with your DNS host and add include:_spf.salesforce.com before the final all term.

TypeHostValue
TXT@v=spf1 include:_spf.google.com include:_spf.salesforce.com ~all
  • Keep one SPF record. Two records that both start with v=spf1 make every check fail, so merge the includes into the record you have.
  • SPF allows 10 DNS lookups in total. Each include uses at least one, so remove senders you no longer use.
  • ~all marks other senders as suspect. Move to -all once your DMARC reports show nothing legitimate failing.

Step 2: Create a DKIM key in Salesforce

DKIM signs each message so the receiver can confirm it came from a sender your domain approved. In Setup, type DKIM in Quick Find, open DKIM Keys, and click Create New Key.

Salesforce Create a DKIM Key form with Key Size, Selector, Alternate Selector, Domain and Domain Match Pattern fields
The four fields to fill in. All of them are required. Source: Salesforce Setup, 15 Nov 2026.
FieldWhat to enterExample
Key Size2048-bit, unless a rule you follow requires another size2048-bit
SelectorA short name that no other sender on the domain usessf2026
Alternate SelectorA second name for the second keysf2026a
DomainThe domain in your From addressesexample.com
Domain Match PatternThe domains this key signs for. Enter the domain alone to cover it, or add *.example.com after a comma to cover subdomains as wellexample.com

Click Save. Salesforce creates the key in an inactive state and takes a short while to prepare the records for the next step.

Step 3: Publish the two CNAME records

Open the key you just made. When TXT Record Status reads Published, the page shows a CNAME Record and an Alternate CNAME Record.

Salesforce DKIM Key Details page showing the CNAME Record and Alternate CNAME Record for a domain
The two records to copy to your DNS host. These values are public DNS. Source: Salesforce Setup, 15 Nov 2026.

Add both with your DNS host, exactly as Salesforce shows them.

TypeHostPoints to
CNAMEsf2026._domainkeysf2026.abc123.custdkim.salesforce.com
CNAMEsf2026a._domainkeysf2026a.def456.custdkim.salesforce.com

Most DNS hosts add the domain to the Host field for you. If you paste the full name there, the record is saved as sf2026._domainkey.example.com.example.com and never resolves. Run the two dig commands from the check above until both answer.

Step 4: Activate the key

Go back to the key in Setup and click Activate. Salesforce signs nothing until you do. The key list then shows a check mark under Active for the domain.

Salesforce Manage DKIM Keys list with three keys, each showing a check mark in the Active column
One key for each sending domain, all active. Source: Salesforce Setup, 15 Nov 2026.

Make one key for every domain that appears in a From address. A key for example.com does nothing for mail sent from example.org.

Step 5: Add a DMARC record

DMARC tells the receiving server what to do when a message fails both SPF and DKIM for your domain, and where to send a daily report. Start with a policy that only reports.

TypeHostValue
TXT_dmarcv=DMARC1; p=none; rua=mailto:dmarc@example.com

Read the reports for a week or two. They name every server sending as your domain, including the ones nobody remembered. When everything legitimate passes, change p=none to p=quarantine, and later to p=reject. Google describes the record in its DMARC setup guide.

Step 6: Verify the From addresses

Salesforce sends only from addresses and domains it has verified. In Setup, open Organization-Wide Addresses. These are the shared From addresses that flows, alerts and users can send as, such as a sales or billing mailbox.

  1. Click Add.
  2. Enter the Display Name and Email Address, choose which profiles may use it, and choose its Purpose.
  3. Save. Salesforce emails a link to that address, and someone with access to the mailbox has to click it.
Salesforce Organization-Wide Email Addresses list with a Status column showing Verified and Verification Request Sent
Read the Status column. An address still waiting on its link cannot be used to send. The addresses are covered. Source: Salesforce Setup, 15 Nov 2026.

A row that reads Verification Request Sent has a Resend link beside it. The red line at the top of this capture is a second thing to watch for: Salesforce wants a verified address set as the Default No-Reply Address.

Individual users are checked too. Salesforce explains both levels in its email verification requirements. To test one domain, open Deliverability in Setup, scroll to Email Domain Status, enter the domain, and click Check Verification.

Lower half of the Salesforce Deliverability page showing the substitute email address setting and the Email Domain Status check
The substitute address setting and the domain check, at the bottom of the Deliverability page. Source: Salesforce Setup, 15 Nov 2026.

When Use a substitute email address for unverified domains is on, mail from a domain you have not verified still goes out, from a Salesforce address in place of yours. Customers see an address they do not recognize, so treat that setting as a safety net and verify the domain. Salesforce describes it here.

Step 7: Set the Deliverability page

Stay on Deliverability and scroll to the top. This page decides whether the org may send at all.

Top half of the Salesforce Deliverability page showing Access level set to All email, bounce management and email security compliance
Access level and the email security compliance box are the two that stop or spoil delivery. Source: Salesforce Setup, 15 Nov 2026.
SettingOptionsProduction value
Access levelNo access, System email only, All emailAll email
Activate bounce managementOn or offOn. Bounces come back to Salesforce and the bad address is flagged
Return bounced emails to senderOn or offYour choice. On sends the bounce to the user as well
Enable compliance with standard email security mechanismsOn or offOn
TLS SettingPreferred, Required, Preferred Verify, Required VerifyPreferred. Required drops mail to any server that cannot encrypt
Verify the ownership of email sending domains by DKIM keysOn or offOptional. Lets an active DKIM key stand as proof you own the domain
Use a substitute email address for unverified domainsOn or off, with an address to useOn, as a safety net

Click Save at the top of the page after any change.

Step 8: Send a test and read the headers

Open Test Deliverability in Setup, enter your own address, and click Send. Salesforce sends a set of test messages from the range of servers it uses, which shows whether your mail server accepts them.

Salesforce Test Deliverability page with one Email Address field
Test Deliverability sends to one address you enter. Source: Salesforce Setup, 15 Nov 2026.

That test proves the mail arrives. To prove it is trusted, send one real email from a Lead or Contact to a Gmail address, open it, click the three dots, and choose Show original. Read three lines:

  • SPF: PASS.
  • DKIM: PASS, with your domain named beside it.
  • DMARC: PASS.

If SPF passes for a Salesforce address and not for yours, look at the Return-Path. Salesforce can use its own return address so it can collect bounces, and in that case the DKIM line is the one that ties the message to your domain. DMARC passes when either check lines up with the From address.

Three mistakes that send mail to spam without an error

None of these raises an error in Salesforce or with the DNS host. The email is sent, and the first sign is a customer who never saw it.

  • The SPF record leaves Salesforce out. The domain was set up for Google years ago and nobody added Salesforce when the first flow started sending.
  • A DKIM record was pasted with its labels. A DKIM TXT value has to begin with v=DKIM1. If the on-screen labels from an admin console are copied along with the key, the record still saves, and every signature fails.
  • Only one of the two CNAME records was published. Mail signed with the first key passes and mail signed with the second fails, so the problem comes and goes.

Set it up in a sandbox

A sandbox uses the same Setup pages as production, with four differences. SPF and DMARC sit on the domain, so they already cover the sandbox and need no change.

The sandbox starts with customer email turned off

A new or refreshed sandbox has Access level set to System email only. That protects real customers from test runs, and it is also why a flow that emails fine in production sends nothing in the sandbox.

Salesforce Deliverability page in a sandbox with Access level set to System email only
The Deliverability page in a sandbox, as Salesforce sets it. Source: Salesforce Setup, 15 Nov 2026, sandbox.
Access levelWhat goes outWhen to use it in a sandbox
No accessNothingA sandbox nobody should email from
System email onlyAutomatic system email such as password resets and new user noticesThe resting state, every day
All emailEverything, including flows, alerts, Apex and user emailOnly while you run a test, then set it back

The sandbox signs with its own DKIM key

Open DKIM Keys in the sandbox. If the list is empty or the key is not active, repeat steps 2 to 4 there. Give the sandbox key selectors that production does not use, such as sfuat2026 and sfuat2026a, because each key gets its own pair of CNAME records on the same domain.

Salesforce Manage DKIM Keys list in a sandbox showing active keys whose selectors include the sandbox name
Sandbox keys with their own selectors, so their records sit beside production's in DNS. Source: Salesforce Setup, 15 Nov 2026, sandbox.

From addresses carry their status over

Open Organization-Wide Addresses in the sandbox and read the Status column again. An address that was still waiting on its link in production can still be waiting in the copy.

The recipients are real people

A sandbox copied from production holds your customers' real email addresses on Leads and Contacts. Salesforce adds .invalid to the email of most users in a new sandbox, and it leaves Leads and Contacts as they are. Before you raise Access level, do three things.

  1. Correct the email on your own user record, and confirm it from the link Salesforce sends.
  2. Create a test Lead or Contact with your own address, and send only to that record.
  3. Check that no scheduled flow or batch job is due to email a list while the level is All email.

Then set Access level to All email, send the test, read the headers as in step 8, and set the level back to System email only the same day.

Every record and setting on one page

ItemWhere it livesWhat good looks like
SPFDNS, TXT on the domainOne record that includes _spf.salesforce.com
Salesforce DKIM keySetup, DKIM Keys2048-bit, Active, one for each sending domain
DKIM CNAME recordsDNS, two CNAMEs under _domainkeyBoth resolve to custdkim.salesforce.com
DMARCDNS, TXT on _dmarcA policy and a reporting address
From addressesSetup, Organization-Wide AddressesEvery row Verified, and a Default No-Reply Address set
Domain statusSetup, Deliverability, Email Domain StatusVerified for each sending domain
Access levelSetup, DeliverabilityAll email in production, System email only in sandboxes
Email security complianceSetup, DeliverabilityOn
Headers on a real messageGmail, Show originalSPF, DKIM and DMARC all pass

Which emails to check first

Start with the messages a customer is waiting for, because a missed one costs a deal or a renewal before anyone looks at DNS.

  • The auto-reply a new lead gets after filling in a form.
  • Quotes, proposals and renewal notices sent from a record.
  • Case replies and status updates from your service team.
  • Appointment and intake reminders sent by a flow.

Send one of each to a Gmail address and a Microsoft address you control, and read the headers on both.

Frequently asked questions

Why are my Salesforce emails going to spam?

Most often the receiving server cannot confirm that Salesforce is allowed to send for your domain. Either the SPF record does not include Salesforce, or there is no active Salesforce DKIM key for the domain. With a DMARC policy of none, that mail is not rejected. It is delivered to spam.

What is the SPF record for Salesforce?

Add include:_spf.salesforce.com to the one SPF record your domain already has. A domain that also sends through Google Workspace ends up with v=spf1 include:_spf.google.com include:_spf.salesforce.com ~all.

How do I set up DKIM in Salesforce?

In Setup, open DKIM Keys and click Create New Key. Enter a selector, an alternate selector, your domain and a domain match pattern. Salesforce gives you two CNAME records. Publish both with your DNS host, then come back and activate the key.

Why does Salesforce DKIM need two CNAME records?

Salesforce keeps two keys for each domain, one on the selector and one on the alternate selector, so it can change keys without a gap in signing. If only one record is published, part of your mail goes out with a signature nobody can check.

Do I need DMARC if SPF and DKIM pass?

Yes. DMARC tells the receiving server what to do when a message fails both checks, and where to send reports. Google asks every sender to authenticate and asks bulk senders to publish a DMARC record. Start with p=none and a reporting address, then tighten it.

Why does my sandbox not send email?

New and refreshed sandboxes start with the Deliverability access level set to System email only, so flows and Apex cannot email customers by accident. Change it to All email for a test, and change it back when you finish. The sandbox also needs its own active DKIM key, with selectors that production does not use.

Official references

GAT Solutions is an independent Salesforce consultancy. Salesforce is a trademark of Salesforce, Inc., and Gmail and Google Workspace are trademarks of Google LLC.

Continue the decision

View all resources →

Free one-page review

Salesforce email landing in spam? Tell us what you send.

A one-page written review within one business day: which records pass, which fail, and what to fix first.

Never send us a key or password.

See Salesforce managed services