Setting up an SPF Record for Google Workspace
Ensuring your emails land in your recipients’ inboxes rather than their spam folders is crucial for effective communication. One of the most fundamental steps in achieving this is setting up a Sender Policy Framework (SPF) record. This article provides a comprehensive guide on configuring an SPF record specifically for Google Workspace, helping you authorize Google to send emails on behalf of your domain and improve your email deliverability.
We’ll walk through the necessary steps to create, implement, and validate your SPF record, covering common issues and best practices along the way. By the end of this guide, you’ll have a properly configured SPF record, enhancing your email reputation and ensuring your messages reach their intended audience.
- Creating the SPF Record
- Adding the SPF Record to Your DNS
- Validating Your SPF Record
- SPF Best Practices and Common Issues
Creating the SPF Record

The first step in setting up SPF for Google Workspace is to create the actual SPF record. An SPF record is a TXT record that you add to your domain’s DNS settings. This record specifies which mail servers are authorized to send emails on behalf of your domain. For Google Workspace, this typically involves including Google’s SPF servers.
The general format of an SPF record is as follows:
v=spf1 <mechanisms> <modifiers>
Let’s break down the components:
- v=spf1: This specifies the SPF version being used. Always use ‘spf1’ as it is the current and only widely supported version.
- <mechanisms>: These define which mail servers are authorized to send emails. Common mechanisms include:
- include: Includes the SPF record of another domain. This is essential for Google Workspace.
- a: Matches the sender’s IP address against the domain’s A record.
- mx: Matches the sender’s IP address against the domain’s MX records.
- ip4: Specifies an IPv4 address or range.
- ip6: Specifies an IPv6 address or range.
- <modifiers>: These modify how the SPF record is evaluated. The most common modifier is:
- redirect=: Redirects the SPF check to another domain’s SPF record.
For Google Workspace, the most straightforward and recommended SPF record is:
v=spf1 include:_spf.google.com ~all
This record instructs receiving mail servers to check Google’s SPF records (_spf.google.com) to determine if the sending server is authorized to send emails for your domain. The “~all” mechanism is a softfail, meaning that emails from servers not listed in the SPF record will be accepted but marked as suspicious. Using “-all” is a hardfail which will likely cause the email to be rejected.
Crafting a More Specific SPF Record (If Needed)In some cases, you might need a more specific SPF record. For example, if you use a third-party hubspot-email-marketing-tactics-to-boost-roi/" class="internal-link" title="3 Hubspot Email Marketing Tactics to Boost ROI">email marketing service in addition to Google Workspace, you’ll need to include their SPF records as well. Here’s how you can combine multiple “include” mechanisms:
v=spf1 include:_spf.google.com include:sendgrid.net ~all
This record authorizes both Google and SendGrid to send emails on behalf of your domain. Remember to replace “sendgrid.net” with the correct domain for your email marketing service. It’s crucial to only include services you actively use to send email from your domain.
Example 1: Basic Google Workspace SPF Record
v=spf1 include:_spf.google.com ~all
This example provides the simplest and most common SPF record for Google Workspace. It authorizes Google servers to send email for your domain. The `~all` at the end signifies a softfail. Email from servers not explicitly authorized may still be accepted, but marked as suspicious.
Example 2: Google Workspace and a Third-Party Email Service
v=spf1 include:_spf.google.com include:mailjet.com ~all
This example expands the SPF record to include Mailjet, a popular email marketing platform, in addition to Google Workspace. This allows both Google and Mailjet servers to send emails on your domain’s behalf. Ensure to replace `mailjet.com` with the actual domain provided by your third-party service.
Example 3: Including Specific IP Addresses
v=spf1 include:_spf.google.com ip4:192.0.2.0/24 ~all
In this example, we’ve added an `ip4` mechanism to authorize a specific range of IP addresses (192.0.2.0/24) in addition to Google Workspace. This can be useful if you have internal servers that also send emails. Be very careful when adding IP addresses; ensure they are valid and controlled by you. Incorrectly configured IP addresses can create deliverability problems.
Important Considerations:
- The 10 DNS Lookup Limit: SPF has a limit of 10 DNS lookups. Each “include,” “a,” “mx,” “ptr,” and “exists” mechanism counts as a lookup. Exceeding this limit will cause SPF to fail, negatively impacting your email deliverability. Keep your SPF records as concise as possible.
- The “all” Mechanism: The “all” mechanism should always be at the end of your SPF record. It specifies what to do with emails that don’t match any of the preceding mechanisms. We recommend starting with “~all” (softfail) and monitoring your email deliverability. If you are confident that your SPF record is correct and comprehensive, you can switch to “-all” (hardfail). However, be cautious when using “-all,” as it can cause legitimate emails to be rejected if your SPF record is not properly configured.
Adding the SPF Record to Your DNS

Once you’ve created your SPF record, the next step is to add it to your domain’s DNS settings. This is typically done through your domain registrar’s website or your DNS hosting provider’s control panel. The specific steps may vary depending on your provider, but the general process is the same.
Here’s a general outline of how to add an SPF record to your DNS:
- Log in to your domain registrar or DNS hosting provider.
- Navigate to the DNS management section. This is often labeled as “DNS Settings,” “Zone Editor,” or something similar.
- Find the section for adding or editing DNS records.
- Create a new TXT record. Select “TXT” as the record type.
- Enter the following information:
- Host/Name: This is usually “@” or your domain name (e.g., “example.com”). Some providers might require you to leave this field blank.
- Value/Content/TXT Value: This is where you paste your SPF record. For example:
v=spf1 include:_spf.google.com ~all
- TTL (Time To Live): This specifies how long DNS servers should cache the record. The default TTL is usually fine (e.g., 3600 seconds or 1 hour).
- Save the record.
It’s important to note that DNS changes can take some time to propagate across the internet. This means that it may take several hours (up to 48 hours in some cases) for your new SPF record to be visible to all mail servers. Be patient and allow sufficient time for propagation before testing your email deliverability.
Example 1: Adding the SPF record in cPanel
- Log in to your cPanel account.
- In the “Domains” section, click on “Zone Editor”.
- Find your domain and click “+ TXT Record”.
- In the “Host Record” field, enter your domain name (e.g., “example.com”) or “@”.
- In the “TXT Value” field, enter your SPF record:
v=spf1 include:_spf.google.com ~all
- Click “Add Record”.
Example 2: Adding the SPF record in Cloudflare
- Log in to your Cloudflare account.
- Select your domain.
- Click on the “DNS” tab.
- Click “+ Add record”.
- Select “TXT” as the type.
- In the “Name” field, enter your domain name (e.g., “example.com”) or “@”.
- In the “Content” field, enter your SPF record:
v=spf1 include:_spf.google.com ~all
- Leave the “TTL” as “Auto”.
- Click “Save”.
Example 3: Adding the SPF record in GoDaddy
- Log in to your GoDaddy account.
- Go to your “My Products” page.
- Find your domain and click “DNS”.
- Click “Add”.
- Select “TXT” as the type.
- In the “Host” field, enter “@”.
- In the “TXT Value” field, enter your SPF record:
v=spf1 include:_spf.google.com ~all
- Leave the “TTL” as the default.
- Click “Save”.
Important notes regarding DNS providers:
- Always double-check the instructions provided by your specific DNS provider. The steps and terminology may vary.
- Be careful when editing existing DNS records. Incorrect changes can disrupt your website and email services.
- If you’re unsure about any step, contact your DNS provider’s support team for assistance.
Many DNS providers are moving towards a format that automatically wraps SPF records within quotes. In these cases, you should enter your SPF record as "v=spf1 include:_spf.google.com ~all"
, including the quotation marks. The system will often handle it automatically and adding extra quotes can cause issues.
Validating Your SPF Record
After adding your SPF record to your DNS, it’s crucial to validate that it’s correctly configured. This ensures that receiving mail servers can properly interpret your SPF record and authenticate your emails. There are several online tools available that can help you validate your SPF record.
Here are some popular SPF record validation tools:
- MXToolbox: https://mxtoolbox.com/spf.aspx
- Dmarcian’s SPF Surveyor: https://dmarcian.com/spf-survey/
- EasyDMARC SPF Record Checker: https://easydmarc.com/tools/spf-record-lookup
To validate your SPF record, simply enter your domain name into one of these tools and run the check. The tool will analyze your SPF record and report any errors or warnings. Common errors include:
- Syntax errors: These are errors in the formatting of your SPF record.
- Too many DNS lookups: SPF records are limited to 10 DNS lookups.
- Missing or incorrect “include” mechanisms: This can prevent Google from being authorized to send emails on your behalf.
- Multiple SPF records: You should only have one SPF record for your domain.
If you encounter any errors, correct them in your DNS settings and revalidate your SPF record. Remember to allow time for DNS propagation after making changes.
Example 1: Validating with MXToolbox
- Go to https://mxtoolbox.com/spf.aspx
- Enter your domain name (e.g., example.com) in the “Domain Name” field.
- Click “SPF Record Lookup”.
- Review the results. MXToolbox will show you your SPF record and indicate whether it is valid. It will also point out any syntax errors or other potential problems.
Example 2: Validating with Dmarcian’s SPF Surveyor
- Go to https://dmarcian.com/spf-survey/
- Enter your domain name.
- The tool will analyze your SPF record and provide a report indicating its validity, DNS lookup count, and any potential issues. It will also suggest improvements.
Using `dig` or `nslookup` from the command line
You can also validate your SPF record using command-line tools like `dig` or `nslookup`. These tools query DNS servers directly and allow you to see the raw DNS records for your domain.
Example using `dig` (Linux/macOS):
dig txt example.com
This command will query the DNS servers for the TXT records associated with your domain. The output will include your SPF record if it is configured correctly.
Example using `nslookup` (Windows):
nslookup -type=txt example.com
This command performs a similar function to `dig`, querying the DNS servers for TXT records. The output will show the SPF record if it exists.
Interpreting the results:
When you use `dig` or `nslookup`, look for a TXT record that starts with “v=spf1”. This is your SPF record. Make sure that the record matches the SPF record you configured in your DNS settings.
If you don’t see any TXT records that start with “v=spf1”, then your SPF record is not configured correctly or has not yet propagated. If you see multiple SPF records, this is also an error. You should only have one SPF record for your domain.
SPF Best Practices and Common Issues
While setting up an SPF record for Google Workspace is relatively straightforward, adhering to best practices and understanding common issues can significantly improve your email deliverability and prevent potential problems. Here are some key considerations:
Best Practices- Keep your SPF record concise: As mentioned earlier, SPF records have a limit of 10 DNS lookups. Avoid unnecessary “include” mechanisms, “a” records, or “mx” records. Only include services that actively send email on behalf of your domain.
- Regularly review your SPF record: As your email infrastructure evolves, your SPF record may need to be updated. For example, if you start using a new email marketing service or change your email hosting provider, you’ll need to update your SPF record accordingly. Set a reminder to review your SPF record at least once a year.
- Use the “include” mechanism whenever possible: Instead of listing individual IP addresses, use the “include” mechanism to delegate authorization to the SPF records of other services. This simplifies your SPF record and reduces the risk of exceeding the DNS lookup limit.
- Start with “~all” and monitor your email deliverability: The “~all” mechanism (softfail) is a good starting point. Monitor your email deliverability to see if any legitimate emails are being marked as spam. If you are confident that your SPF record is correct and comprehensive, you can switch to “-all” (hardfail).
- Combine SPF with DKIM and DMARC: SPF is just one part of a comprehensive email authentication strategy. Implement DKIM (DomainKeys Identified Mail) and DMARC (Domain-based Message Authentication, Reporting & Conformance) to further enhance your email security and deliverability. DMARC builds upon SPF and DKIM to provide more robust protection against email spoofing and phishing attacks.
- Multiple SPF records: This is a common mistake. You should only have one SPF record for your domain. If you have multiple SPF records, receiving mail servers may not be able to properly authenticate your emails. Merge the records into a single SPF record.
- Syntax errors: Even a small typo in your SPF record can cause it to fail. Double-check your SPF record for any syntax errors. Use an online SPF record validator to identify and correct any errors.
- DNS propagation delays: After making changes to your SPF record, it may take some time for the changes to propagate across the internet. Be patient and allow sufficient time for propagation before testing your email deliverability. You can use online tools to check the DNS propagation status of your SPF record.
- Exceeding the DNS lookup limit: As mentioned earlier, SPF records are limited to 10 DNS lookups. If your SPF record exceeds this limit, it will fail. Simplify your SPF record by removing unnecessary mechanisms or using the “include” mechanism whenever possible.
- Incorrectly configured “all” mechanism: The “all” mechanism should always be at the end of your SPF record. Using “+all” is generally not recommended, as it allows any server to send emails on behalf of your domain. Start with “~all” and monitor your email deliverability before switching to “-all”.
Example 1: Troubleshooting multiple SPF records
If you find that you have two SPF records, you need to merge them into one. For example, if you have these two records:
v=spf1 include:_spf.google.com ~all
v=spf1 include:sendgrid.net ~all
You should combine them into a single record like this:
v=spf1 include:_spf.google.com include:sendgrid.net ~all
Delete the old, redundant SPF record.
Example 2: Addressing DNS lookup limit issues
If your SPF record exceeds the 10 DNS lookup limit, you need to simplify it. One way to do this is to use the “include” mechanism instead of listing individual IP addresses. For example, if you have a record like this:
v=spf1 a mx ip4:192.0.2.0/24 ip4:198.51.100.0/24 ~all
And you know that these IP addresses belong to a specific service, check if that service publishes an SPF record and use “include” instead. If there is no published SPF record then you may consider removing the A and MX entries. Listing specific IP addresses should be a last resort.
Example 3: Dealing with DNS propagation delays
After making changes to your SPF record, you can check its propagation using online tools like What’s My DNS. This tool allows you to check your DNS records from multiple locations around the world to see if the changes have propagated to those locations. If the changes haven’t propagated to all locations, wait a few more hours and check again.
By following these best practices and addressing common issues, you can ensure that your SPF record is properly configured and that your emails are delivered reliably to your recipients’ inboxes. Remember that SPF is an evolving standard, so it’s important to stay up-to-date on the latest best practices and recommendations.