X
X
X
X

Knowledge Base

HomepageKnowledge BaseDomain Name RegistryHow to Create an SPF Record: Writin...

How to Create an SPF Record: Writing and Checking SPF for Your Domain

In short: An SPF record is a DNS TXT record that starts with "v=spf1" and lists the servers allowed to send email on behalf of your domain. The receiving mail server looks up this record and checks whether the server that sent the message is on the list. To create an SPF record, find out which servers send your email, combine them into a single TXT record, add it in your domain's DNS management and check it once it has propagated.

What is an SPF record and how does it work?

SPF (Sender Policy Framework) lets a domain publish through DNS which servers may send email for it (RFC 7208). The receiving server reads the SPF record of the envelope sender (MAIL FROM) domain and compares the IP address of the connecting server with it. The result can be pass, fail, softfail or neutral. For what a TXT record is in general, see DNS records (A, MX, CNAME, TXT) explained.

SPF record: a v=spf1 mx ~all TXT record for example.com, the receiving server looking it up, pass, softfail and fail results and qualifiers

1. Which servers send your email?

Before you write the record, list everything that sends email with your domain: the mail server in your hosting account, business email services such as Google Workspace or Microsoft 365, form notifications from your website, and newsletter or invoicing services. A sender you forget can have its messages rejected or sent to spam once the SPF record goes live.

2. Check your existing SPF record

Your domain may already have an SPF record. You can see its TXT records in a terminal with:

dig +short TXT caphosting.net

On 16 November 2026 the SPF record returned for caphosting.net was:

"v=spf1 ip4:38.3.138.185 a mx ~all"

On Windows you can use nslookup -type=TXT yourdomain.com. Both commands are explained in DNS checks with dig and nslookup. If a record exists, do not add a new one; edit the existing record instead, because more than one SPF record on a domain causes an error (permerror).

3. Write the SPF record

The record always starts with v=spf1 and ends with all. The main mechanisms in between are:

  • ip4: / ip6: allow a specific IP address or range.
  • a allows the address in the domain's A/AAAA record; mx allows the domain's MX servers.
  • include: pulls in another domain's SPF record. Google Workspace uses include:_spf.google.com (Google) and Microsoft 365 uses include:spf.protection.outlook.com (Microsoft).
  • A final ~all asks for softfail for servers not on the list, -all asks for fail. The qualifiers are + pass, ~ softfail, - fail and ? neutral.

For example, if you only send email through the server named in your MX record, the record can be v=spf1 mx ~all. If you also use Google Workspace, combine them as v=spf1 mx include:_spf.google.com ~all. If you are not sure which server sends your mail, open a support ticket and confirm before you publish the record.

4. Add the record in DNS management

  1. Open DNS management wherever your domain's nameservers are hosted.
  2. Add a new TXT record; for the root domain the name (host) field is usually @ or left empty.
  3. Paste your SPF record into the value field without quotation marks and save.

5. Common SPF record mistakes

  • Two separate SPF records: Instead of adding a new record for each service, combine all senders in one record.
  • The 10 DNS lookup limit: If the terms that need DNS lookups, such as include, a and mx, add up to more than 10, the SPF check returns an error. Remove includes you no longer need.
  • Using +all: It allows everyone and makes the record pointless.
  • The ptr mechanism: RFC 7208 advises against using it.

6. Verify the record

The change can take time to appear depending on the record's TTL (DNS propagation). Then run the dig command again and send a test message to a Gmail address of your own. Open the message in Gmail, choose "Show original" and check that the SPF line says PASS. SPF is not enough on its own; it works together with DKIM and DMARC. If your messages still land in spam, read why are my emails going to spam.

Frequently Asked Questions

Should I use ~all or -all?

If you are not sure that every sender is listed, starting with ~all is less risky. Once the list is complete, -all makes receivers reject unauthorised senders more clearly.

Can I add more than one SPF record?

No. More than one SPF record on a domain makes the SPF check fail with an error. Combine all senders in a single record.

When does an SPF record change take effect?

Once the record has propagated in DNS. The time depends on the record's TTL and on resolver caches.

Does an SPF record fix spam problems on its own?

Not necessarily. SPF is evaluated together with DKIM and DMARC, and content and sending habits also affect spam decisions.

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(46 times viewed / 0 people found it helpful)

Powered by WISECP
Top