Domain IP Lookup

DKIM 检查:查看您的 DKIM 记录

DKIM 让发信服务器用私钥为每封邮件签名,接收方则用发布在 DNS 中的公钥来验证签名。输入您的域名和邮件服务商使用的选择器来获取这个公钥,然后查看它的长度、格式,以及签名可能失败的原因。

选择器是该域名所发邮件的 DKIM-Signature 头中 s= 的值。

试试:

如何找到您的 DKIM 选择器

一个域名可以同时拥有多个 DKIM 密钥,分别用于不同的服务或密钥轮换,而选择器就是指明使用哪一个的标签。每个密钥都位于 selector._domainkey.yourdomain.com,所以 google._domainkey 和 s1._domainkey 可以并存。

最快的查找办法:给自己发一封邮件,打开完整的邮件头,查看 DKIM-Signature 这一行。其中 s= 的值是选择器,d= 是签名的域名。

不确定结果是什么样子?上方的示例按钮分别展示了健康的 2048 位密钥(yahoo.com,选择器 s2048)、会触发弱密钥警告的 1024 位密钥(yahoo.com,选择器 s1024),以及已吊销的密钥(gmail.com,选择器 20230601)。

部分服务商默认使用的选择器

这些会因服务商和账户的设置方式而异,所以请把它们当作起点,并向您的服务商确认。

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=example.com; s=selector1;
 h=from:to:subject:date:message-id;
 bh=BASE64-BODY-HASH...; b=BASE64-SIGNATURE...
服务商常见选择器
Google Workspacegoogle(较新的密钥使用以日期命名的选择器)
Microsoft 365selector1 和 selector2
SendGrids1 和 s2
Mailchimpk1、k2 和 k3
许多控制面板和主机商default

如何阅读 DKIM 记录

标签含义
v=DKIM1版本。可选,但如果存在则必须为 DKIM1
k密钥类型:rsa(默认)或 ed25519
pbase64 编码的公钥。值为空表示该密钥已被吊销
t=y测试模式:接收方可能对验证失败比较宽容
t=s严格:签名域名必须与 From 域名完全一致
s该密钥可用于哪些服务:email 或 *

密钥长度、拆分与轮换

  • 请使用 2048 位的 RSA 密钥。1024 位的密钥仍可通过验证,但已不再推荐,更短的则不安全。
  • 2048 位的密钥比单个 DNS 字符串能容纳的 255 个字符更长,所以会作为同一条 TXT 记录中的多个带引号字符串发布。大多数 DNS 管理后台会自动替您处理。如果密钥被截断了,就无法读取。
  • 请不时轮换密钥。先发布新的选择器,让邮件服务商改用它来签名,并把旧选择器保留到已在传输途中的邮件投递完毕。
  • 要停用某个密钥,请发布 p= 为空的记录,让用它生成的签名干净地失败,而不是让记录凭空消失。
dig +short TXT selector1._domainkey.example.com
"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..." "...IDAQAB"

nslookup -type=TXT selector1._domainkey.example.com

Resolve-DnsName -Name selector1._domainkey.example.com -Type TXT

dig +short CNAME selector1._domainkey.example.com
selector1-example-com._domainkey.tenant.example.net.

Selectors some providers use by default

These vary by provider and by how an account was set up, so treat them as a starting point and confirm with your provider.

ProviderCommon selectors
Google Workspacegoogle (and a date-based name for newer keys)
Microsoft 365selector1 and selector2
SendGrids1 and s2
Mailchimpk1, k2 and k3
Many control panels and hostsdefault

Reading a DKIM record

TagMeaning
v=DKIM1The version. Optional, but it must be DKIM1 if present
kKey type: rsa (the default) or ed25519
pThe public key, in base64. An empty value means the key is revoked
t=yTesting mode: receivers may be lenient about failures
t=sStrict: the identity in i= must be in the same domain as d=, not a subdomain
sWhich services the key may be used for: email or *

Key types and sizes

KeyLength of p= valueHow the tool rates it
RSA under 1024 bitsUnder about 216 charactersProblem: too weak to trust
RSA 1024 bitsAbout 216 charactersWarning: still verifies, 2048 is recommended
RSA 2048 bitsAbout 392 charactersGood
Ed2551944 characters (32 bytes)Good if exactly 32 bytes after decoding

RFC 8301 sets the floor at 1024 bits for signers and recommends at least 2048. Ed25519 keys, defined in RFC 8463, are short and fast, but some receivers do not verify them yet, so a sender that uses Ed25519 usually signs with an RSA key as well. The lengths above are approximate because they depend on how the key is encoded.

Key size, splitting and rotation

  • Use a 2048-bit RSA key. 1024-bit keys still verify but are no longer recommended, and anything shorter is unsafe.
  • A 2048-bit key is longer than the 255 characters one DNS string can hold, so it's published as several quoted strings inside one TXT record. Most DNS dashboards do that for you. If a key gets truncated instead, it can't be read.
  • Rotate keys from time to time. RFC 6376 sets no schedule, so pick an interval you will actually keep. Publish a new selector first, switch your mail provider to sign with it, and leave the old selector in place until mail already in transit has been delivered.
  • To retire a key, publish the record with an empty p= so signatures made with it fail cleanly instead of the record vanishing.

When the key is fine and DKIM still fails

A published key only means receivers can fetch it. The Authentication-Results header on a failed message says what happened, and the wording differs between receivers, but the cases below are the usual ones.

Result on the messageUsual meaning
dkim=noneThe message carried no DKIM-Signature. Signing is not switched on for this sender
dkim=fail, body hash mismatchThe body changed after signing: a footer, a disclaimer, or re-encoding by a gateway or mailing list
dkim=fail, signature did not verifyThe DNS key does not match the private key in use, often after a key was regenerated but not republished
dkim=permerror or no keyThe name in s= and d= has no usable record: a typo, a wrong domain, or a truncated key
dkim=pass but dmarc=failThe signature is valid but d= is not the From domain, so it does not align

常见问题

指南