sale background store
store logo
Join 1 million+ sellers & claim your .store domain now!
BUY NOW
supportcentre scaled
Support Centre
Find the answers to your questions and get the support you need with the VentraIP help centre.

What is SPF Flattening?

SPF Flattening is a process which takes an existing SPF record with multiple nested records and essentially, “flatten” the record so it only contains a list of IP addresses.

This technique is mainly used to get around the 10 DNS lookup limit as the more email services you use, the more sending servers you will have to include in your SPF record. This can lead to being over the 10 DNS lookup limit which causes the SPF record to be invalid, thus rejecting all emails.

How it works

Say you have the following SPF record: v=spf1 +a +mx include:spf.synergywholesale.com include:_spf.google.com ~all

A mail server will perform a DNS lookup on the domains to find the IP addresses of the authorised senders within the “include” mechanism. In this example it will do an DNS lookup of _spf.google.com and spf.synergywholesale.com

The DNS lookup result will look like the following: _spf.google.com v=spf1 ip4:74.125.0.0/16 ip4:209.85.128.0/17 ip6:2001:4860:4864::/56 ip6:2404:6800:4864::/56 ip6:2607:f8b0:4864::/56 ip6:2800:3f0:4864::/56 ip6:2a00:1450:4864::/56 ip6:2c0f:fb50:4864::/56 ~all

spf.synergywholesale.com v=spf1 ip4:112.140.176.8 ip4:103.42.108.0/24 ip4:103.252.154.214/31 ip4:43.241.52.0/24 ip6:2400:8f80:0:11::/64 -all

This will show all the IP addresses for each providers mail servers. A flattened record would remove the includes and combine all the IP addresses into one record.

Below is an example of a flattened SPF record using the examples above: v=spf1 ip4:74.125.0.0/16 ip4:209.85.128.0/17 ip6:2001:4860:4864::/56 ip6:2404:6800:4864::/56 ip6:2607:f8b0:4864::/56 ip6:2800:3f0:4864::/56 ip6:2a00:1450:4864::/56 ip6:2c0f:fb50:4864::/56 ip4:112.140.176.8 ip4:103.42.108.0/24 ip4:103.252.154.214/31 ip4:43.241.52.0/24 ip6:2400:8f80:0:11::/64 -all

Using a flattened SPF record

It can be pretty ugly having an SPF record that is just IP addresses, and sometimes you can hit the TXT DNS record character limit of 255 due to the amount of IP addresses you have to include.

Instead, create a separate DNS record with your flattened record and include it in your SPF record.

Using the example flattened record above we would create a DNS record similar to the following:

  • Hostname: spf.yourdomain.com (replace yourdomain.com with your own domain.)
  • Record Type: TXT
  • Value: v=spf1 ip4:74.125.0.0/16 ip4:209.85.128.0/17 ip6:2001:4860:4864::/56 ip6:2404:6800:4864::/56 ip6:2607:f8b0:4864::/56 ip6:2800:3f0:4864::/56 ip6:2a00:1450:4864::/56 ip6:2c0f:fb50:4864::/56 ip4:112.140.176.8 ip4:103.42.108.0/24 ip4:103.252.154.214/31 ip4:43.241.52.0/24 ip6:2400:8f80:0:11::/64 -all

Then to include your flattened record, you would just simply add it to your existing SPF record which can look like the following: v=spf1 include:spf.yourdomain.com ~all

Instead of having multiple includes, you would only include the one flattened record.

Downsides to SPF flattening

Senders adding or changing their IP addresses: Flattened records won’t automatically be updated when a provider updates their SPF record. Manually having to manage flattened records: Since you have to manually manage flattened records, it can be a bit tedious keeping up with mail providers IP address changes.

To get around this, you can use SPF flattening services which is able to monitor your providers, and update your SPF record.

Need help?

Since SPF flattening is more advanced, feel free to get in touch with our technical support team and we are happy to assist with anything SPF related!

misc content center scaled