SPF flattening: pros, cons and safer options
Flattening swaps include: entries for the IP addresses behind them, to get under SPF's 10-lookup limit. It works, but breaks silently when a service changes its addresses. What flattening is An SPF record may use at most 10 DNS lookups. Each include: costs at least one, and the services you include often add more. Flattening replaces each include with the IP addresses it points to ( ip4: and ip6:…
Flattening is a technique used in Sender Policy Framework (SPF) records to reduce the number of DNS lookups required by replacing include statements with the actual IP addresses they point to. Each include statement in an SPF record uses up one of the ten allowable DNS lookups. However, flattening can lead to issues when a service changes its IP addresses, as the flattened list becomes outdated and may cause email delivery problems.
Pros of flattening include:
1. Eliminating the need to exceed the 10-lookup limit, which ensures your email sends successfully.
2. Eliminating the need to modify email services to accommodate changes in SPF records.
Cons of flattening include:
1. The flattened list becomes stale, and any changes to the IP addresses behind include statements will not be reflected. This can result in email delivery failures without any warning.
2. Long SPF records may need to be split into multiple records, making them harder to read and check.
3. Flattening can make the record harder to understand and audit.
Safer options to consider:
1. Remove any unused services from your SPF record. This will often fix most records that are too long or complex.
2. Move a bulk sender to its own subdomain and create a separate SPF record for that subdomain. This helps to keep your SPF record clean and manageable.
3. Rely on DomainKeys Identified Mail (DKIM) for tools that support it. This way, these tools won't need to be included in your SPF record for DMARC to pass.
If you still need to flatten your SPF record, it is essential to use a service that automatically updates the list of IP addresses. Additionally, it is crucial to monitor your DMARC reports to ensure that flattening is not causing any issues with email delivery.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.