The "CharacterStringTooLong" error arises when your Sender Policy Framework (SPF) record, specifically a DNS TXT record, exceeds the maximum allowable length. This often happens after attempting to "flatten" an SPF record, which aims to reduce DNS lookups but can inadvertently create a single, lengthy string that surpasses DNS provider limits, typically 255 characters per string within a TXT record. While SPF flattening is crucial for avoiding the 10-DNS-lookup limit, it's vital to ensure the flattened record also adheres to DNS TXT record size constraints. This issue can significantly impact email deliverability, leading to authentication failures and messages being marked as spam or rejected outright.
Key findings
TXT record limit: A standard DNS TXT record string has a character limit of 255 characters. Exceeding this limit, even with SPF flattening, triggers the "CharacterStringTooLong" error.
Flattening tools limitations: While SPF flattening tools reduce DNS lookups, some might not account for the fundamental 255-character TXT record string limit, producing records that are still too long for DNS providers.
Multiple strings in one record: DNS RFCs allow a single TXT record to contain multiple strings, which should be concatenated by the DNS client. However, some DNS providers or resolvers may not handle this as expected, or the combined length can still exceed an internal provider limit.
Impact on deliverability: A broken or improperly configured SPF record due to length issues will lead to SPF authentication failures, increasing the likelihood of emails being sent to spam or rejected.
Key considerations
Manual splitting: When encountering this error, you may need to manually split your SPF record into multiple 255-character strings within the same DNS TXT record to comply with limits. For guidance on structuring these records, refer to our article on how to format SPF TXT records.
Dynamic IP ranges: If your SPF record includes numerous IP ranges that frequently change, a static flattened record may quickly become outdated. This can lead to broken SPF records and deliverability issues.
Review inclusions: Before resorting to flattening, carefully evaluate all included domains in your SPF record. Remove any unnecessary or outdated include mechanisms to reduce overall length and DNS lookups.
DNS provider specifics: While RFCs specify 255 characters per string, some DNS providers might have unique interpretations or additional limitations. Always consult your DNS provider's documentation for their specific TXT record handling, as noted in general SPF record syntax guides.
Email marketers often grapple with the practicalities of SPF record management, especially when dealing with multiple sending services. The immediate appeal of SPF flattening tools is clear: reduce DNS lookups to avoid authentication failures. However, the nuance of DNS TXT record limits can turn a solution into a new problem, leading to the dreaded "CharacterStringTooLong" error. Marketers highlight the confusion and frustration when automated tools don't fully address these underlying technical constraints.
Key opinions
Unexpected errors: Many marketers encounter the "CharacterStringTooLong" error even when using SPF flattening tools, suggesting these tools may not fully account for DNS TXT record length limitations.
Tool reliability: There's a concern that some flattening services might simplify DNS lookups without properly segmenting the output into valid TXT record lengths, leading to new issues.
Manual checks: Marketers are advised to manually check the character length of their flattened SPF records in a plain text editor to ensure they are within the 255-character string limit per TXT record.
Dynamic IP management: There's an awareness that relying on flattened SPF records with hardcoded IP addresses can be problematic if those IPs change frequently, necessitating a dynamic solution.
Key considerations
Beyond lookups: While minimizing DNS lookups is critical, marketers must also be aware of the separate and equally important DNS TXT record string length limits. Learn more about managing DNS TXT record length limits.
Evaluating tools: When using SPF flattening tools, verify if they output a single TXT record string that complies with the 255-character limit, or if they offer instructions for splitting it into multiple strings.
Understanding 'a' records: Be mindful of how 'a' records affect DNS lookups and the 10-lookup limit within SPF. Understanding this impact is key to effective SPF management.
Long-term strategy: Consider whether SPF flattening is a long-term solution, especially if it hardcodes IP addresses. Evaluate if a dynamic SPF service, which automatically updates records, is more suitable for your sending infrastructure, as discussed in industry discussions on SPF flattening.
Marketer view
Email marketer from Email Geeks notes that SPF flattening for a client on Route 53 resulted in a 'CharacterStringTooLong' error, prompting investigation into potential syntax issues or tool limitations.
29 Oct 2019 - Email Geeks
Marketer view
Email marketer from Email Geeks explains they tried splitting their SPF record across multiple DNS entries (3 or 4) but still encountered the 'CharacterStringTooLong' error, indicating a deeper problem than simple single-record length.
29 Oct 2019 - Email Geeks
What the experts say
Experts in email deliverability emphasize that SPF record issues, particularly length constraints, are common pitfalls. They distinguish between the SPF 10-lookup limit and the fundamental DNS TXT record string length limit, which often causes the "CharacterStringTooLong" error. Their advice centers on understanding the underlying DNS mechanics, careful record construction, and recognizing the limitations of automated flattening tools, especially for long-term reliability and adaptability to changing IP environments.
Key opinions
TXT record vs. SPF record: Experts clarify that the "CharacterStringTooLong" error is a DNS TXT record limitation (255 characters per string) separate from the SPF 10-DNS-lookup limit. An SPF record can span multiple strings within a single TXT record, but each string must be under 255 characters.
Flattening tool limitations: Automated SPF flattening services often focus solely on reducing DNS lookups and may not properly segment the output into strings that comply with the DNS TXT record's 255-character length constraint.
Manual control recommended: For complex SPF configurations, experts often suggest a more manual approach or tools that provide detailed information, empowering users to understand and manage their records effectively, rather than fully automated solutions.
Dynamic SPF solutions: If IP addresses in the SPF record frequently change, an expert might recommend a dynamic SPF management service that automatically re-flattens and updates the record, maintaining compliance without manual intervention.
Key considerations
Beyond basic SPF: SPF record management requires a nuanced understanding of both the SPF specification and DNS limitations. This deeper dive is part of advanced email authentication guidance.
Error interpretation: Distinguish between an SPF TempError related to DNS lookups and a `CharacterStringTooLong` error, which indicates a TXT record length issue. Our guide helps in demystifying SPF TempError.
Long-term vs. quick fixes: While quick flattening can fix immediate lookup issues, it might not be the best long-term strategy for domains with frequently changing sending infrastructure. This is often highlighted in expert opinions on spam and deliverability resources.
Comprehensive authentication: Always view SPF in the context of a complete email authentication strategy, including DKIM and DMARC, to ensure robust email security and deliverability.
Expert view
Email expert from Email Geeks clarifies that DNS TXT records are limited to 255 characters. They explain that SPF records that exceed this limit, even if split across subdomains, must be further split into multiple consecutive TXT record strings on the same domain to comply with the standard.
29 Oct 2019 - Email Geeks
Expert view
Email expert from Email Geeks suggests that SPF flattening services often perform DNS lookups but may fail to create appropriately segmented TXT records. They mention never personally relying on a service to automatically handle the entire SPF creation process.
29 Oct 2019 - Email Geeks
What the documentation says
Technical documentation outlines the precise specifications for DNS records, including TXT records used for SPF. The core of the "CharacterStringTooLong" error stems directly from these foundational rules. RFCs and other authoritative sources detail the character limits for individual strings within a TXT record, as well as how multiple strings are to be handled by DNS clients. Understanding these specifications is critical for proper SPF implementation and avoiding common configuration errors, especially when SPF records grow complex.
Key findings
RFC 1035 compliance: DNS TXT records, as defined in RFC 1035, can contain character strings up to 255 characters long. This is the primary limit triggering the error.
Multiple string concatenation: A single TXT record can be composed of multiple strings, which are intended to be concatenated by the DNS client before interpretation. However, improper implementation by DNS providers can lead to issues even if individual strings are within limits.
SPF record length recommendation: RFC 7208 (SPF) recommends that the string of an SPF RR (resource record) should not be longer than 255 characters, reinforcing the DNS TXT record string limit.
Vendor-specific limitations: Some DNS providers may impose additional, stricter limits on the total length of a TXT record, or how they handle multiple strings, which can vary from the RFC specifications. Amazon Web Services, for example, has specific guidance for splitting long records.
Key considerations
Adherence to RFCs: To prevent CharacterStringTooLong errors, ensure your SPF TXT records strictly adhere to the 255-character string limit as per DNS RFCs. This fundamental rule underpins what RFCs say about email standards.
Splitting long records: If an SPF record, even after flattening for lookups, exceeds the string limit, it must be divided into multiple quoted strings within a single TXT record entry, with each string not exceeding 255 characters.
Syntax for multiple strings: The correct syntax for multiple strings within one TXT record typically involves enclosing each segment in double quotes. DNS resolvers are then expected to concatenate these segments automatically.
Optimizing record length: Before resorting to splitting, review the SPF record for redundancy or unnecessary include mechanisms that could be causing the excessive length. This falls under broader technical solutions for email deliverability.
Technical article
Documentation from RFC 1035, Section 3.3.14, outlines that TXT RRs are designed to hold descriptive text, and the value within these records is a character string which can be up to 255 characters long, directly addressing the limit for each string.
Nov 1987 - RFC 1035
Technical article
Documentation from RFC 7208 (SPF) specifies that the string of an SPF Resource Record (RR) should not be longer than 255 characters, reinforcing the fundamental DNS TXT record string length constraint for SPF implementation.