When trying to add a long TXT record, such as a DKIM or SPF record, you may run into errors. Inside this article, we'll explain what causes these error messages and how you can resolve them.
What Causes TXT Record Length Errors?
Per RFC 1035 section 2.3.4, TXT records are limited to 255 characters. For that reason, attempting to add a TXT record that is longer than this character limit will result in an error.
If your TXT record is longer than 255 characters, you may be required to split it into multiple records.
Solution: Split Long TXT Records Into Smaller Records
For TXT records that are longer than 255 characters, the solution is simple: split the record into multiple records.
Splitting DKIM Records
DKIM records can get quite lengthy, so splitting them is sometimes unavoidable. To split a DKIM record, you'll just need to cut the string into multiple parts like this:
Original
v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvZS9fshwGNVhtPtZkuHnODAr66RVIplc0HkqDKElfW6h7yMJGYCvJ5PYDzLn3ek6TfwHFrcFNMDuWaNg8wm3W1cofTRQyftMMvW0hMj+/l4wciJVEiKDGzCvEMuN/vh3LeoShe2cs2/RxQjPTduuNfRd60X+VkcE1JFMmqwvsCkJYqTw/knc2Kj90nczPMg6Yb4qYqD4tOmZbHM3fDSqiXOedcttn884turoyeSl690TfhnIIdf3CG3kPcplx8N6HP1TPmWaDtUHpyklErL8K1o2pm/BWiIRApPJzuU54QKiP2acJ/tWKNcK1UV8ctP/K0Wm/TDBDHwHidsGkYS9nQIDAQAB
Split
v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvZS9fshwGNVhtPtZkuHnODAr66RVIplc0HkqDKElfW6h7yMJGYCvJ5PYDzLn3ek6TfwHFrcFNMDuWaNg8wm3W1cofTRQyftMMvW0hMj+/l4wciJVEiKDGzCvEMuN/vh3LeoShe2cs2/RxQjPTduuNfRd60X+VkcE1JFMmqwvsCkJYq
Tw/knc2Kj90nczPMg6Yb4qYqD4tOmZbHM3fDSqiXOedcttn884turoyeSl690TfhnIIdf3CG3kPcplx8N6HP1TPmWaDtUHpyklErL8K1o2pm/BWiIRApPJzuU54QKiP2acJ/tWKNcK1UV8ctP/K0Wm/TDBDHwHidsGkYS9nQIDAQAB
As you can see from the example above, all we needed to do is break the record in half, then apply it as 2 records.
Simplify Long SPF Records
Domains and subdomains can only have one effective SPF record, so it's important to make it as efficient as possible. In the event your SPF record exceeds the 255 character limit, you can consolidate ip:
items by creating SPF records under different subdomains which can then be added to your SPF record as include:
items.
Let's use the following SPF record as an example:
v=spf1 ip4:123.12.123.456 ip4:12.34.56.123 ip4:123.45.123.456 ip4:12.345.6.123 ?all
To simplify this record we can create an additional SPF records under different subdomains, such as spf1.example.com or spf2.example.com.
spf1.example.com SPF - v=spf1 ip4:123.12.123.456 ip4:12.34.56.123 ?all
spf2.example.com SPF - v=spf1 ip4:123.45.123.456 ip4:12.345.6.123 ?all
You can then add them as include:
items in your main SPF record:
v=spf1 include:spf1.example.com include:spf2.example.com ?all