SPF record generator
Generating the record runs in the browser and requires JavaScript. A fixed example is shown.
Everything runs in your browser; nothing is sent or stored.
- In the "The domain servers" section, select the mechanisms you need (a, mx), and enter IPv4 addresses, IPv6 addresses, and domains to include, one value per line.
- Selecting a provider name in the "Common mail providers" section adds its include to the record, and selecting it again removes it.
- In the "Servers not in the record (all)" section, choose the result: reject, mark as suspicious, or no policy.
- Copy the "TXT record value" and the "Record name (Host)". A record longer than the TXT string limit is also shown split into strings. A domain must have only one SPF record. If a TXT record starting with v=spf1 already exists, update it instead of adding another one, since two records make the check fail (permerror).
- An SPF record alone does not protect the domain from spoofing: it checks only the sending server and the domain of the return address (Return-Path), not the sender address the recipient sees. Set up DKIM signing and a DMARC record as well. You can create the DMARC record with the DMARC record generator.
What is an SPF record
An SPF (Sender Policy Framework) record is a TXT record on a domain that starts with v=spf1 and lists the servers allowed to send mail for the domain. The receiving server checks whether the IP address of the sending server is authorized in the SPF record of the domain in the return address (Return-Path). The mechanisms in the record are checked in order, and the first mechanism that matches the sending server sets the result. The sign before each mechanism sets the type of result: - to reject, ~ to mark as suspicious, ? for no policy, and +, or a mechanism with no sign, to allow.
The 10 DNS lookup limit
The include, a, mx, ptr, and exists mechanisms, as well as the redirect modifier, each need a DNS lookup during the check. RFC 7208 limits the check to 10 such lookups, including the lookups of the records pulled in with include, and a record that exceeds the limit fails the check (permerror). The ip4 and ip6 mechanisms need no lookup, so IP addresses listed directly in the record do not count toward the limit. When a record gets close to the limit, you can remove the includes of services that are no longer in use.
The difference between -all and ~all
The all mechanism at the end of the record sets the result for a server that is not listed in the record. -all asks the receiving server to reject the message, and ~all asks it to accept the message and mark it as suspicious. When you first set up a record, ~all keeps legitimate messages from being rejected when they come from a service that is not in the record yet, such as an email marketing platform, a CRM system, or a contact form on your website. Once every service that sends mail for the domain is included in the record, you can switch to -all.
Example records
v=spf1 mx -allOnly the incoming mail servers of the domain, according to its MX records, are allowed to send, and the result for any other server is a rejection.v=spf1 ip4:192.0.2.0/24 -allEvery address from 192.0.2.0 to 192.0.2.255 is allowed to send, and the record needs no DNS lookups.v=spf1 mx include:example.net ~allThe incoming mail servers of the domain and the servers authorized in the SPF record of example.net are allowed to send, and messages from other servers are marked as suspicious.v=spf1 redirect=example.netThe check uses the SPF record of example.net, so several domains of the same organization can share one record.v=spf1 -allA record for a domain that sends no mail at all: no server is allowed to send mail for the domain.v=spf1 +allAny server is allowed to send mail for the domain, so the record does not protect it. That is why the generator does not offer this value.
With our business email service, an SPF record and DKIM signing are set up automatically for your business domain, and they confirm to the recipients' mail servers that the messages really came from your business.
SPF record generator FAQ
Can I set up two SPF records for the same domain?
No. A domain must not have two SPF records, because two records that start with v=spf1 make the check fail (permerror). When you add a service that sends mail for the domain, add its include to the existing record, before the all mechanism.
Does an SPF record protect the sender address the recipient sees?
An SPF record does not directly protect the sender address the recipient sees, because it checks the domain in the return address (Return-Path), not the domain in the sender address (From). That is why a spoofed message with your domain in the sender address may pass the SPF check when its return address belongs to another domain. A DMARC record requires the domain checked by SPF or DKIM to align with the domain in the sender address, and sets how to handle a message that does not meet this requirement.
Should I use the SPF record type instead of a TXT record?
No. Set up the SPF record as a TXT record only. The SPF record type was once defined in the standard, but RFC 7208 deprecated it, and receiving servers read only the TXT record.
When should I use redirect instead of include?
With include, only the servers authorized in the record of the included domain are added to the record, and the result for all other servers is set by the all mechanism of the record itself. With redirect, when no mechanism in the record matched, the record of the target domain is checked instead, including its all mechanism. That is why include suits authorizing a mail provider or another service, and redirect suits a domain that follows a shared record of the organization.