Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Free tool · SEO and webmaster

SPF record generator

Pick who sends mail as your domain and the generator writes one SPF line, for example v=spf1 mx a ip4:192.0.2.0/24 include:_spf.example.net ~all, then counts its DNS lookups and tells you where to publish it.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

Who sends mail as your domain?
One per line. IPv4 or IPv6, with an optional range such as /24. The example addresses are reserved for documentation: replace them.
One domain per line, exactly as the service's own setup page gives it. This one is an example.
Mail from any other server
Only used to show where to publish the record.

Runs in your browser. Nothing you type is sent anywhere, and no DNS lookup is made.

Result

Your SPF recordOne TXT record, ready to copy

  • 3 / 10 lookups
  • 58 characters
  • 4 terms
v=spf1 mx a ip4:192.0.2.0/24 include:_spf.example.net ~all
Where to publish it
Record type
TXT
Name
@, the domain itself
Value
the line above, exactly as shown
What to know
  • Good Ending in ~all (softfail) marks mail from unlisted servers as probably not authorized, without asking receivers to reject it on this result alone.
  • Note 3 of the 10 DNS lookups are used by the terms you chose. Each include can add more inside its own record, so run the finished record through the SPF record checker.
  • Note A domain may have only one SPF record. If one already exists, put these terms into it instead of adding a second line: two records make SPF fail (RFC 7208 section 4.5).

How to use the SPF Record Generator

  1. Tick the senders you use: your mail servers, your website server, or both. Tick This domain sends no email if it never does.
  2. Type IP addresses or ranges, one per line, and any include domains your mail services gave you.
  3. Choose what happens to mail from any other server: ~all to mark it suspicious or -all to ask for rejection.
  4. Press Copy record and add it as a TXT record at your domain. Check it afterwards with the SPF record checker.

How do I write an SPF record?

An SPF record is one line of text that starts with v=spf1, lists the senders you allow, and ends with an all term. With the example choices above the generator writes v=spf1 mx a ip4:192.0.2.0/24 include:_spf.example.net ~all. That is 58 characters and 3 DNS lookups. RFC 7208 defines the format, and you publish the line as a TXT record on your domain.

Read left to right. mx allows the servers in your MX records. a allows the address of your domain itself. ip4:192.0.2.0/24 allows a block of 256 addresses. include:_spf.example.net says that whatever that domain's own SPF record allows is allowed for you too. The last term, ~all, covers everybody else.

The generator checks what you type before it writes anything. A mistyped IP address, a range with too large a number after the slash, or an include that is not a domain name gets a message that names the exact entry.

Which senders should I list?

List every system that sends email with your domain in the sender address, and nothing else. That usually means your own mail server or hosted mailbox, plus any outside service that sends for you, such as a newsletter tool, a billing system or a help desk. Forgetting one means its mail can fail SPF.

Choose between mx and a by where your mail really leaves from. If your mail is sent by the same servers that receive it, mx covers them. If it is sent by the machine that your website name points to, a covers that machine. When neither is true, for example because a hosted service sends the mail, leave both unticked and use that service's include or its IP ranges. Listing a source that does not send only widens the door.

Each kind of entry has its own cost. Plain IP addresses and ranges need no DNS lookup. The mx, a and include terms each count as one of the 10 lookups RFC 7208 allows. The table shows what the generator writes for each choice.

What each choice adds to the record
ChoiceTerm writtenDNS lookups
My mail servers (MX)mx1
My website server (A)a1
One IPv4 addressip4:192.0.2.100
An IPv4 rangeip4:192.0.2.0/240
An IPv6 rangeip6:2001:db8::/320
A service to includeinclude:_spf.example.net1

For an include, copy the domain exactly as the service gives it. The generator cannot look it up, because it makes no network request. It counts the include as one lookup, but the record behind it can use more. Paste the finished line into the SPF record checker to see the full count with every include opened.

Should I end with ~all or -all?

Both are valid, and the choice is how firmly you say no. RFC 7208 describes -all as an explicit statement that a server is not authorized, and receivers may reject such mail. It describes ~all as a weak statement that the server is probably not authorized, and says receivers should not reject mail on that result alone.

Because a forgotten sender fails under -all, ~all is the gentler start. Switch to -all once you are sure the list is complete. A domain that never sends mail is different: v=spf1 -all allows nobody, and the generator writes exactly that when you tick the box.

If you leave the all term off, RFC 7208 treats unmatched senders as neutral, as if you had written ?all. That says nothing useful, so the generator always ends the record with one of the two.

How long can an SPF record be, and how many includes can it have?

It can trigger at most 10 DNS lookups. The generator adds up the mx, a and include terms you chose and warns at 8 or 9. Over 10, receivers return an error and SPF fails for every message, so the generator marks it as a problem. RFC 7208 adds two limits it cannot test offline: no more than two void lookups, which are questions that come back empty, and no more than 10 addresses behind one mx term. A stale include or a dead mail host trips the first. Includes are the usual cause, since each one can bring in more includes of its own.

Length matters too. A single piece of DNS text holds up to 255 characters, and RFC 7208 allows a record to be split into several pieces that are joined with no space between them. When your record passes 255 characters, the generator shows it cut into quoted pieces for panels that ask for that. Section 3.4 of the RFC also suggests keeping the whole answer under about 450 characters so it fits one small DNS packet. The table counts single addresses to show how fast that grows.

Record length when listing single IPv4 addresses
AddressesCharactersResult
128Fits in one piece
596Fits in one piece
10182Fits in one piece
20362Needs 255-character pieces
40722Over 450: shorten

Ranges save space. One /24 covers 256 addresses in 16 characters, so list a range when the whole block is yours.

Where do I publish the record, and what about my other records?

Publish it as a TXT record at your domain. Most DNS panels call the name @, or let you leave it empty. Paste the line exactly as shown, without extra quotation marks unless the panel asks for them.

A domain may have only one SPF record. If you already have one, merge the new terms into it. RFC 7208 says two records make the check fail with a permanent error. SPF is also only one of three checks. To tell receivers what to do with mail that fails, the DMARC record generator writes the next record, and the DKIM checker looks at the signing key.

All the work happens on this page. What you type stays here and no DNS query is made, which is why an include name is taken on trust and not verified.

Use it with

Questions

How do I create an SPF record?

Choose your senders, pick ~all or -all, and copy the line the generator writes, for example v=spf1 mx a ip4:192.0.2.0/24 include:_spf.example.net ~all. Publish it as one TXT record on your domain.

What is the difference between ~all and -all?

-all asks receivers to reject mail from unlisted servers. ~all marks it as probably not authorized, and receivers should not reject on that alone (RFC 7208).

How many DNS lookups can an SPF record use?

Ten. The terms include, a, mx, ptr and exists, plus redirect, each count as one. IP addresses and ranges do not count.

Can I have two SPF records on one domain?

No. Two records make SPF return a permanent error. Merge them into one line.

What SPF record do I use for a domain that sends no email?

v=spf1 -all. It allows no server to send as the domain. Tick "This domain sends no email" and the generator writes it.

Does this generator send my data anywhere?

No. Everything is worked out on the page without any request, so an include domain is not verified either.

How this page was made: the tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations were drafted with AI help and checked against the tool's own output.