SPF Record Generator Email

An SPF record generator turns a list of the servers that send email for a domain into the TXT record that authorizes them. Select the mail services the domain uses, add any servers of your own, and copy the finished record. The counter shows how many DNS lookups the record needs, because SPF stops working above 10.

Used for the host name and the check links below. The record is built in your browser.

Services that send mail for the domain

Use the exact value from the provider's setup instructions. Some providers give each customer a different one.

Your own servers
Mail from any other server

SPF record to publish

Type
TXT
Host
@
Value

The count is the worst case: every mechanism evaluated, nested includes read from live DNS through a public resolver (dns.google).

    How to use the SPF generator

    1. List every sender. Tick each service that sends mail using the domain: the mailbox provider, plus any marketing, billing, help desk or CRM platform that sends as the domain. A sender that is left out fails SPF.
    2. Add your own servers. Enter the IP addresses or CIDR ranges of mail servers and applications you run. Use mx or a only if those hosts really send mail.
    3. Choose the rule for everyone else. ~all is the usual choice; see the comparison below.
    4. Check the lookup count, then copy the value into a TXT record at the root of the domain. If a record starting with v=spf1 already exists, replace it.
    5. Verify. Once the record is live, run the domain through the SPF Analyzer to confirm what receivers see.

    What each part of an SPF record means

    PartMeaningDNS lookups
    v=spf1Version tag. It must come first, and it is what marks a TXT record as SPF.0
    ip4: ip6:One address or a CIDR range that is allowed to send.0
    aThe addresses in the domain's own A and AAAA records.1
    mxThe addresses of the hosts in the domain's MX records.1
    include:Also accept whatever the SPF record of another domain accepts. This is how a mail service is authorized.1, plus the lookups inside the included record
    allMatches every other sender. The qualifier in front of it sets the result.0

    Mechanisms are read left to right and the first match wins, which is why all goes last. The generator leaves out ptr, which RFC 7208 says should not be used, and +all, which would authorize every server on the internet.

    The 10-lookup limit

    RFC 7208 allows a receiver to make at most 10 DNS lookups while it evaluates one SPF record. The include, a, mx, exists and ptr mechanisms and the redirect modifier each cost one; ip4, ip6 and all cost none. Lookups inside an included record count too, so a single include can use several. Going over the limit produces a permanent error (PermError), and DMARC treats that as an SPF fail for every message.

    The counter above reads the current record of each include from DNS and adds up the worst case. Providers change their records without notice, so check a published record from time to time with the SPF Analyzer. If the count is too high, the usual fixes are to remove services that no longer send, to replace an include with the provider's IP ranges where those are stable, or to send one mail stream from a subdomain that has its own SPF record. The guide to the SPF lookup limit covers each option.

    ~all or -all

    • ~all (soft fail) tells receivers that other servers are probably not authorized. Mail is normally accepted and scored as suspicious. With a DMARC policy in place this is the common choice, because DMARC decides what happens to failing mail and a message that fails SPF can still pass on DKIM.
    • -all (fail) states that no other server is authorized. Some receivers reject on that result alone, before DKIM and DMARC are evaluated, which can drop forwarded mail. It is the right ending for a domain that sends no mail at all.
    • ?all (neutral) makes no statement and gives no protection. It is only useful for a short test.

    Where the record goes

    Publish the value as a TXT record on the domain itself (host @). The old dedicated SPF record type was withdrawn; only TXT is used. Three details catch people out:

    • Subdomains do not inherit SPF. If mail is sent from news.example.com, that name needs its own record.
    • SPF checks the envelope sender, the Return-Path address, and not the From address a reader sees. Many bulk senders use a bounce domain of their own, or ask for a subdomain to be delegated to them. Follow the provider's instructions about which host name gets the record.
    • Long records are split. One TXT string holds 255 characters. A longer value is published as several quoted strings in the same record, which receivers join back together.

    SPF on its own does not stop someone forging the visible From address. That takes DMARC, which ties the SPF and DKIM results to the From domain. Once SPF is published, create the policy record with the DMARC record generator.

    Frequently asked questions

    What does an SPF record generator do?

    It assembles the SPF TXT record for a domain from the senders you select: mail services (added as include: mechanisms), your own servers (ip4:, ip6:, a, mx) and a closing all rule. The output is the exact value to paste into a TXT record at the root of the domain.

    Can a domain have more than one SPF record?

    No. If two TXT records starting with v=spf1 exist on the same name, receivers return a permanent error and SPF fails for all mail. When a new service has to be authorized, add its mechanism to the existing record.

    What counts toward the SPF 10-lookup limit?

    Each include, a, mx, exists and ptr mechanism and the redirect modifier costs one DNS lookup, and so does every such term inside an included record. ip4, ip6 and all cost nothing. More than 10 lookups is a permanent error.

    Should an SPF record end in ~all or -all?

    For a domain that sends mail and has a DMARC policy, ~all is the usual choice: DMARC decides what happens to failing mail, and receivers still evaluate DKIM. -all is stricter and some receivers reject on it immediately. Use -all for domains that never send email.

    What SPF record should a domain that sends no email publish?

    v=spf1 -all. It says that no server is authorized, so any message claiming to come from the domain fails SPF. Pair it with a DMARC record set to p=reject so that parked and unused domains cannot be spoofed.

    How long does a new SPF record take to work?

    Receivers that have the old record cached keep using it until its TTL runs out, typically between five minutes and a day. Receivers with nothing cached see the new record at once.

    Last updated: