Why flatten your SPF record?
Let’s review where we got to. Our example SPF record has come from the fact that we use Office 365 for our company email, we use MailChimp for marketing newsletters, and we use AuthSMTP for our online store.
As a result of each provider’s requirement we have an SPF record that looks like it only contains three DNS lookup whereas it actually contains eight:
“v=spf1 include:spf.protection.outlook.com include:servers.mcsv.net include:authsmtp.com -all”
Now suddenly our business has engaged with a partner who’s going to handle all the emails related to our credit card processing, and they need to be added to our SPF record. Their SPF record is for MyPaymentCompany.com and includes two additional include statements for spf-a.mypaymentcompany.com and spf-b.mypaymentcompany.com.
That’s another three DNS lookups so without any warning we’ve suddenly and immediately breached the limit of ten DNS lookups. We’ve got to add the SPF record because otherwise our customers won’t get their online payment receipts. But if we add the record then all of our marketing emails and our regular business emails are going to start getting flagged as spam – because the receiving email server MUST return a PermError due to our invalid record.
Getting out of a Jam
The answer here is to do something called SPF Flattening. But as we’ll see that’s actually only half the answer.
SPF Flattening means that we take each of those SPF records and resolve them to all of their individual IP addresses. We then replace the include statements with a long list of ip4 statements which don’t require any DNS lookups and thus don’t put us at risk of being rejected.
Taking just Office 365, our SPF record would now look like this:
v=spf1 ip4:220.127.116.11/15 ip4:18.104.22.168/16 ip4:22.214.171.124/14 ip4:126.96.36.199/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 ip4:188.8.131.52/24 ip4:184.108.40.206/24 ip4:220.127.116.11/27 ip4:18.104.22.168/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 -all
That might not look great to you and me, but it looks just fine to an email server!
If we repeat this process for the MailChimp record, the AuthSMTP record and the Credit Card company’s record then suddenly we have a super long SPF record, but it’s filled with nice clean ip4 and ip6 statements, and no DNS-heavy include statements:
“v=spf1 ip4:22.214.171.124/15 ip4:126.96.36.199/16 ip4:188.8.131.52/14 ip4:184.108.40.206/17 ip6:2a01:111:f400::/48 ip6:2a01:111:f403::/48 ip4:220.127.116.11/24 ip4:18.104.22.168/24 ip4:22.214.171.124/27 ip4:126.96.36.199/27 ip6:2a01:4180:4051:0800::/64 ip6:2a01:4180:4050:0800::/64 ip6:2a01:4180:4051:0400::/64 ip6:2a01:4180:4050:0400::/64 ip4:188.8.131.52/20 ip4:184.108.40.206/18 ip4:220.127.116.11/24 ip4:18.104.22.168/22 ip4:22.214.171.124/23 ip4:126.96.36.199/24 ip4:188.8.131.52/23 ip4:184.108.40.206/25 ip4:220.127.116.11/25 ip4:18.104.22.168/23 ip4:22.214.171.124/24 ip4:126.96.36.199/24 ip4:188.8.131.52/23 ip4:184.108.40.206/24 ip4:220.127.116.11/24 ip4:18.104.22.168/25 ip4:22.214.171.124/22 ip4:126.96.36.199/22 ip4:188.8.131.52/22 ip4:184.108.40.206/23 ip4:220.127.116.11/23 ip4:18.104.22.168/23 ip4:22.214.171.124/28 -all”
So why is this only half the answer?
Well the reason that Microsoft want you to include spf.protection.outlook.com (which additionally references spfd.protection.outlook.com) is that they need to change these IP addresses from time to time. They’ll upgrade their infrastructure, change internet service providers, change their routing, any of which could result in emails leaving the Office 365 cloud from a different IP address. They can’t contact each Office 365 customer to tell them to change their SPF IP addresses every time that happens, hence why they ask you to use an include statement which references a DNS record over which they have complete control.
So if you flatten spf.protection.outlook.com today and then look again in six month’s time, I can guarantee it won’t be the same. That’s a problem because if your Office 365 emails are going out from one of Microsoft’s new IP addresses then the receiving email server, your customer’s, is going to treat it as spam. Suddenly all of your business emails are now going to your customers’ spam folders.
Hence – automated SPF Flattening from proSPF. Read on to find out more.