SPF record generator

Tick the services that send mail for your domain and get one valid SPF record, with the DNS lookups it costs counted before you publish it.

Build your SPF record

Which services send mail for this domain

Tick every service that sends mail from an address at this domain. The value after each name is the include that goes into the record.

Zoho is built in with the value for the European data centre. An account in another region uses include:zoho.com, so change that one entry by hand after you copy the record.

Your own servers

Separate several entries with a space or a comma. An address costs no DNS lookup at all, an include costs at least one.

What happens to mail from anywhere else

What the record actually says

An SPF record is one line of text published as a TXT record on the domain. It lists the servers allowed to send mail with an address at that domain, and it ends by saying what to do about everybody else.

v=spf1
Marks the line as an SPF record. A TXT record that does not start with this is not SPF and is ignored.
ip4, ip6
A single address or a range that may send. These cost no DNS lookup, which makes them the cheapest way to authorise your own server.
a, mx
The addresses of the domain itself, and the hosts named in its MX records. One DNS lookup each.
include
Hands the question over to the record of another domain, which is how a mail provider keeps its own sending addresses up to date. At least one DNS lookup, often several.
-all, ~all
The closing term. Everything that did not match one of the mechanisms before it falls to this one.

The terms are read from left to right and the first one that matches decides the answer, so the record puts the addresses first and the includes after them.

How this SPF record generator counts DNS lookups

RFC 7208 allows no more than ten DNS lookups while a record is evaluated, and the lookups made inside an include count towards the same ten. Some providers publish one flat record that costs exactly one lookup. Others include further records of their own, and then a single line in your record can quietly cost half of the ten by itself.

That is why this page does not stop at writing the line out. It follows the record it has just built, expands every include the way a receiving mail server would, and prints the running total with the cost of each entry next to it. The number is measured on the spot, not guessed from a table, because provider records change without telling anyone. Cross the limit and receivers return permerror, which most of them treat exactly like a failed check, so a record over the limit protects nothing and breaks delivery at the same time.

If the count comes back close to ten, the way out is usually one of two things: remove a service that is no longer in use, or replace one include with the ip4 ranges behind it. Ranges cost nothing to evaluate, but they stop being correct the day the provider changes them, so keep them for your own servers.

Only one record, and never +all

A domain may publish exactly one SPF record. Two of them are a permerror for every receiver, even when each line is correct on its own, and this is the single most common way a working setup gets broken: a new service is added, its record is pasted in next to the old one, and mail starts failing for everything. When a service is added, its include goes into the record that is already there.

The builder refuses two things on purpose. It will not put a second v=spf1 line into a record, and it will not write +all. A record ending in +all authorises every server on the internet to send mail as your domain, which is the same as publishing no record at all, except that it also looks deliberate.

Start with ~all, finish with -all

With -all you state that no other server is authorised, and receivers may refuse the message outright. With ~all the message is accepted and marked as suspicious, which usually means the spam folder.

The order that works is: publish the record with the senders you know about, watch what actually fails for a week or two, then switch the last term to -all. Domains lose real mail by going to -all before anyone has checked the invoicing system, the newsletter tool and the contact form on the website. Those are the three that get forgotten.

Do not use ?all. It says the record has no opinion, which is what receivers assume in the absence of a record anyway.

After you publish it

Add the record in the DNS zone of the domain as a TXT record on the name @, which is the domain itself, and give a resolver as long as the TTL to notice it.

Frequently asked questions

How do I create an SPF record for my domain?

Tick the services that send mail with your address, add your own server addresses if it sends mail directly, pick what happens to everything else, and copy the line into your DNS as a TXT record on the domain itself. There is nothing to install and nothing to sign up for.

Can I have two SPF records?

No. Two v=spf1 records give permerror and the check fails as a whole, even when each record is correct on its own. Every sender has to be merged into one record, which is what this page builds.

What do I do if I use several mail services?

They all go into the same record, one include each. Watch the lookup counter while you add them: several large providers together can pass the limit of ten DNS lookups, and at that point the record stops working for everyone.

Should the record end in -all or ~all?

End it in -all once you are sure the list of senders is complete, because that is the version receivers act on. Use ~all while you are still collecting them, and switch as soon as you have checked the invoicing, the newsletter and the website forms.

Why is the lookup count higher than the number of services I picked?

Because an include hands the question over to another domain, and that record can include further records again. Every one of them costs a lookup against the same limit of ten, so a single service can cost four or five on its own. The list under the record shows what each entry expands into, and that is the number a receiving mail server really spends.

Does this publish the record for me?

No. Nothing is changed on your side: the page reads the public DNS and builds the line, and you paste it into your own DNS panel. Publishing it is the one step that has to happen where the domain is managed.