Question: How do I set up an SPF record for my Google Workspace domain?
Explanation: An SPF (Sender Policy Framework) record is a piece of text (a TXT record) that you add to your domain's DNS at your domain provider. To put it simply: your domain grants permission to a sending mail server (for example Google, Brevo, or your own website) to send email on behalf of your domain from their server (IP address).
The domain contains a text snippet in which you grant permission to a sending server, and other mail servers recognise this. As a result, emails you send through Google or any other party via your domain don't get flagged as SPAM. You can check which TXT records exist in your domain by visiting the Dig (Domain Information Groper) tool by Google.
- Match, the IP is on the list: the email passes the SPF check.
- No match: depending on the policy at the end of the record (
or~all
) the email is marked as suspicious or rejected.-all
SPF works on the basis of the envelope sender (the Return-Path), not the visible From address. That is an important difference with DKIM and DMARC, and the reason SPF alone is not enough to fully prevent spoofing.
- SPF (Sender Policy Framework) defines which servers may send on behalf of your domain.
- DKIM (DomainKeys Identified Mail) uses a digital signature to verify that the email was not altered in transit.
- DMARC (Domain-based Message Authentication, Reporting and Conformance) tells receiving servers what to do when SPF or DKIM fails, and sends reports back to the domain owner.
Solution:
To set up an SPF record you need access to the DNS environment of the domain. This can be done through providers such as TransIP, Cloudflare, GoDaddy, Namecheap, Plesk or DirectAdmin. There you can edit TXT records via the DNS settings of the domain.
In most cases an SPF record already exists in the domain, added by the DNS host or another administrator. You can usually add Google by including
include:_spf.google.comin the existing record, between
v=spf1and
~all(or
-all).
Does your domain have no SPF record yet? Then add the following:
v=spf1 include:_spf.google.com ~allv=spf1.
v=spf1 records side by side, SPF will fail for all senders. In that case, combine all authorised senders into a single record.
include:_spf.google.com before ~all or -all. A record that initially only allowed Brevo would then look like this:
v=spf1 include:spf.brevo.com include:_spf.google.com ~all
Create a new SPF record: add a new TXT record with the following values:
| Field | Value |
|---|---|
| Type | TXT |
| Name/Host | @ (or leave empty, depending on your provider) |
| Value | v=spf1 include:_spf.google.com ~all |
| TTL | Default (usually 3600 seconds) |
SPF: you should see 'PASS' with your domain.
Components of an SPF record explained:
| Mechanism | Description and values | Explanation |
|---|---|---|
| v | SPF version, must be the first tag in the record: v=spf1 | This is how the server recognises the protocol. |
| ip4 | Authorises mail servers by IPv4 address or address range. Example: ip4:192.168.0.1 | This is where you can give your web server access via its IPv4 address. |
| ip6 | Authorises mail servers by IPv6 address or address range | This is where you can give your web server access via its IPv6 address. |
| a | Authorises mail servers based on the domain name | If you want to send from your web server, you can add a to allow this. |
| mx | Authorises Mail eXchange records of domains | If you want your mail server to send via for example one IP address, add mx to the line. |
| include | Authorises third-party email senders per domain. Example: include:servers.mail.net | An external SPF record can be imported and used within your own domain. |
| all | All incoming messages must match the record | Not applicable. |
| ~all | Softfail qualification, receiving mail servers accept messages but flag them as suspicious | Emails get the benefit of the doubt. |
| -all | Fail qualification, receiving mail servers may reject messages | Emails that do not match the SPF record are rejected immediately. |
include, a, mx, ptr or exists in your record counts, including lookups that happen inside imported records.
Going above 10 results in a
permerror and SPF fails entirely. Solutions include SPF flattening (using static IP addresses instead of include) or using an SPF macro management tool.