Skip to content

Set up SPF and DKIM: Get your emails delivered

What SPF and DKIM do, how the records are structured and how to set them up for every service that sends emails from your domain.

Rocketprovide teamUpdated on 5 min read
Email with your own domain
  • Reading time5 minutes
  • Updated30/11/2026
  • Sections8
  • AuthorRocketprovide team

In short

SPF and DKIM are two DNS records that prove emails from your domain really come from you. SPF names the servers that may send in your name, and DKIM adds a digital signature to every email. Without them, your emails end up in spam more often or are rejected.

Why emails without SPF and DKIM end up in spam

Receiving servers such as Gmail or Outlook check every email to see whether the sender is genuine. Without SPF and DKIM they cannot verify this and filter the email out as a precaution. Since February 2024, Gmail has required at least SPF or DKIM from all senders, and both plus DMARC from senders of more than 5,000 emails a day to Gmail addresses.

SPF: who may send in your name?

SPF stands for Sender Policy Framework. It is a TXT record on the domain itself, named @ in the customer portal, and it starts with v=spf1. This is followed by the authorised senders and, at the end, a rule for all other servers.

How the Rocketprovide Microsoft 365 template sets the SPF record
@TXTv=spf1 include:spf.protection.outlook.com -all
Parts of an SPF record
PartMeaning
v=spf1Marks the record as SPF.
include:…Includes the authorised servers of a service, such as spf.protection.outlook.com for Microsoft 365 or _spf.google.com for Google Workspace.
ip4:…Allows a single IPv4 address or a network, such as ip4:203.0.113.20.
a and mxAllows the servers from the A or MX record of the domain.
-allNo other servers are allowed (strict).
~allAll other servers count as suspicious, but the email is usually still accepted (soft).

SPF for several services

If you send through several services, such as Microsoft 365 and a newsletter tool, they all go into a single record:

One SPF record for two services
@TXTv=spf1 include:spf.protection.outlook.com include:spf.newsletter.example -all
  • Only one SPF record per domain. Two records make SPF invalid.
  • No more than 10 DNS lookups: every include, a and mx counts, including the lookups in included records. If there are more, SPF fails.
  • Each service gives you the value for include in its instructions.

DKIM: the digital signature

DKIM stands for DomainKeys Identified Mail. The sending server signs every email with a private key. You publish the matching public key in DNS. The recipient uses it to check whether the email really comes from your service and has not been altered on the way.

The key is always generated by the service that sends the emails. You only enter it. The record name contains a selector so that several keys can exist side by side:

DKIM records of well-known services
ServiceRecord nameType
Microsoft 365selector1._domainkey and selector2._domainkeyCNAME
Google Workspacegoogle._domainkeyTXT
Newsletter servicesdepends on the service, such as s1._domainkeyCNAME or TXT

These names are the usual defaults. What counts is what the service shows you during setup. Today, 2048-bit keys are common, and check the minimum key size required by your email provider.

How the receiving server checks an email

  1. The receiving server reads the sender domain from the envelope of the email, known as the Return-Path.
  2. It looks up the SPF record of this domain and compares the IP address of the sending server with the authorised senders.
  3. It reads the DKIM signature from the email header and fetches the public key via the selector, such as google._domainkey.meinefirma.at.
  4. It uses the key to check that the content and important header fields are unchanged.
  5. Finally, it uses DMARC to check whether the verified domains match the visible sender address, and applies your policy.

Set up SPF and DKIM step by step

  1. List every service that sends emails from your domain: mailboxes, newsletters, shop, accounting and website forms.
  2. Get the include value for SPF and the DKIM record from each service.
  3. In the Rocketprovide customer portal, open the domain and then DNS. For Microsoft 365 and Google Workspace, the template sets the SPF record at the same time.
  4. Add further services to the existing SPF record instead of creating a second one.
  5. Add the DKIM records and switch on DKIM at each service.
  6. Check the result by sending a test email to a Gmail address and opening “Show original”.

With DMARC you decide what happens to emails that fail SPF and DKIM.

Continue with DMARC

Check SPF and DKIM

  • Command line: dig TXT meinefirma.at shows the SPF record, dig TXT google._domainkey.meinefirma.at the DKIM key for Google Workspace.
  • Gmail: in the test email you received, “Show original” lists SPF and DKIM with PASS or FAIL.
  • DMARC reports: they show which servers pass SPF and DKIM. More on this in the article DMARC explained.

Common mistakes

  • Two SPF records, for example after changing email provider.
  • A typo in the include, such as a missing underscore in _spf.google.com.
  • DKIM record added but DKIM not switched on at the service.
  • DKIM key not copied in full: copy the value without spaces or line breaks.
  • SPF only on the domain although a subdomain such as news.meinefirma.at sends emails: the subdomain needs its own record.

Frequently asked questions

What is the difference between SPF and DKIM?

SPF checks whether the sending server is authorised. DKIM checks whether the email itself is genuine and unchanged. The two complement each other, and DMARC evaluates them together.

Should I use -all or ~all?

Both are common. -all is strict and declares all other servers unauthorised. ~all is softer and suits a transition period. Microsoft recommends -all, Google ~all.

How many includes can an SPF record have?

A total of 10 DNS lookups is allowed. Every include counts, plus the lookups in the included records.

Do I need to rotate DKIM keys?

Regular rotation is recommended. Microsoft 365 uses two selectors for this, so the switch works without interruption.

Do I need SPF if I do not send emails?

Yes, it is a good idea. The record v=spf1 -all shows that no emails come from this domain. Together with DMARC, this makes it harder to misuse your domain for phishing.

What does softfail mean?

Softfail is the result of ~all when a server that is not authorised sends an email. The email is usually accepted but marked as suspicious and ends up in spam more often.

Do SPF and DKIM also apply to subdomains?

SPF only applies to the name the record is on. If a subdomain such as news.meinefirma.at sends emails, it needs its own SPF record. You add DKIM keys for every domain that signs.

Read more

Related articles

All guide articles

Check your domain

Enter the name you want and see which extensions are available. DNS templates and DNSSEC are included.