#2921: Can a TXT or SPF record be longer than 255 characters?
SPF record does not support more than 255 characters in a single string. So if we attempt create an SPF record with more than 255 characters in single string, NIOS will return an error "Invalid text string".
Following are two workarounds with examples.
- Using double quoted (" ") strings in an SPF record to split the long string to multiple short strings.
Let's say the SPF string you are not able to update is : (Using some random IP addresses in the example)
@ IN TXT "v=spf1 ip4:244.11.23.13 ip4:188.8.131.52 ip4:184.108.40.206 ip4:244.182.23.191 ip4:220.127.116.11 a mx ?all"
This can be modified by splitting the string in to two, each string less than 255 characters like this :
@ IN TXT "v=spf1 ip4:244.11.23.13 ip4:18.104.22.168" " ip4:22.214.171.124 ip4:244.182.23.191" " ip4:126.96.36.199 a mx ?all"
The reading application omits the double quotes and concatenates all of the string into one record.
- Create multiple sub SPF records and concatenate them into one string using the "Include" statement.
If the actual long SPF record is the same as the above example, we can split the record to two SPF records as shown below:
@ IN TXT _spf1 IN TXT "v=spf1 ip4:244.11.23.13 ip4:188.8.131.52 a mx ?all"
@ IN TXT _spf2 IN TXT "v=spf1 ip4:184.108.40.206 ip4:244.182.23.191 ip4:220.127.116.11 a mx ?all"
Then create a third SPF record with the include statement as below to concatenate both the SPF records in to one.
@ IN TXT "v=spf1 include:_spf1.myhost.com include:_spf2.myhost.com a mx ?all"