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:
v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvZS9fshwGNVhtPtZkuHnODAr66RVIplc0HkqDKElfW6h7yMJGYCvJ5PYDzLn3ek6TfwHFrcFNMDuWaNg8wm3W1cofTRQyftMMvW0hMj+/l4wciJVEiKDGzCvEMuN/vh3LeoShe2cs2/RxQjPTduuNfRd60X+VkcE1JFMmqwvsCkJYqTw/knc2Kj90nczPMg6Yb4qYqD4tOmZbHM3fDSqiXOedcttn884turoyeSl690TfhnIIdf3CG3kPcplx8N6HP1TPmWaDtUHpyklErL8K1o2pm/BWiIRApPJzuU54QKiP2acJ/tWKNcK1UV8ctP/K0Wm/TDBDHwHidsGkYS9nQIDAQAB
v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvZS9fshwGNVhtPtZkuHnODAr66RVIplc0HkqDKElfW6h7yMJGYCvJ5PYDzLn3ek6TfwHFrcFNMDuWaNg8wm3W1cofTRQyftMMvW0hMj+/l4wciJVEiKDGzCvEMuN/vh3LeoShe2cs2/RxQjPTduuNfRd60X+VkcE1JFMmqwvsCkJYq
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.
Splitting SPF Records
To split SPF records, just create multiple records that contain the IPs/CIDR ranges that you need.
For example, you could split them like this:
v=spf1 ip4:220.127.116.11 ip4:18.104.22.168 ip4:22.214.171.124 ?all
v=spf1 ip4:126.96.36.199 ?all
v=spf1 ip4:188.8.131.52 ?all
v=spf1 ip4:184.108.40.206 ?all
As long as the record is under 255 characters, feel free to split them as you see fit. The important part is that each record is a complete SPF record that is under the required character limit.