大网数据广告活动
网站运营与故障问答

Do SPF and DKIM TXT records require quotes?

· 52CE 我爱测

I have been searching for some hours now, but multiple sources say different things. https://support.wordfly.com/hc/en-us/articles/204767474-How-do-we-publish-DKIM-and-SPF-in-our-DNS- States I should not include quotes, whereas h…

问题原文

原帖链接 · Neograph734 · CC BY-SA 3.0

I have been searching for some hours now, but multiple sources say different things.

https://support.wordfly.com/hc/en-us/articles/204767474-How-do-we-publish-DKIM-and-SPF-in-our-DNS- States I should not include quotes, whereas https://stackoverflow.com/a/9784925/1293725 reads quotes should be included in these TXT records.

These are just some examples of sources, but there are many more.

So should these records include quotes or not?

已采纳解答

原帖链接 · MrWhite · CC BY-SA 4.0

In the (raw) DNS zone file, the value of a TXT record needs to be enclosed in double-quotes if it contains spaces (as is often the case with SPF and DKIM records). Spaces are otherwise delimiters in the DNS Zone file.

RFC 1035 defines how values should be quoted in the Zone fine. With regards to TXT resource records:

3.3.14. TXT RDATA format

+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
/                   TXT-DATA                    /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

where:

TXT-DATA One or more <character-string>s.

[Page 20]

<character-string> is expressed in one or two ways: as a contiguous set of characters without interior spaces, or as a string beginning with a " and ending with a ". Inside a " delimited string any character can occur, except for a " itself, which must be quoted using \ (back slash).

[Page 35]


However, as mentioned in comments, you often use another tool to edit DNS records (you don't usually edit the DNS zone file directly, although WHM does give you this option). This other tool will probably handle the quotes and any additional escaping that is required to make the record valid. If you manually surround the value in quotes when submitting the value using your editor/tool then these additional quotes might be escaped and become part of the TXT record value.

Incidentally, when you do a DNS lookup, you are seeing the parsed/unquoted string value.

Further Reference:
https://en.wikipedia.org/wiki/TXT_Record
https://www.rfc-editor.org/rfc/rfc1464

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2015-11-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。