Received も同じく先頭に付け足される。RFC 5321 の 4.4 節は、SMTP サーバは Received を「メッセージの先頭に」挿入し、既存の Received を変更・削除してはならないとしている。したがって、受け取ったサーバが付けた本物の結果は、最初の Received より上にある。Received より下にある Authentication-Results は、途中のサーバか送信者が書いたものである。
自社のサーバが RFC 8601 5節どおりに古い行を消していれば偽の行は届かない。しかし、ヘッダを貼り付けて調べる場面では、その前提が成り立っているかが分からないことが多い。そこで「最初の Received より上」と「自分の authserv-id」の2つで絞る。
exportconst { unfold, decodeWords, receivedDate, field } = ctx;
// render() の中の認証結果の拾い方と同じ正規表現 exportfunctionauthTags(headers) { const out = []; for (const h of headers) { if (h.name.toLowerCase() !== 'authentication-results') continue; const re = /\b(spf|dkim|dmarc|arc|compauth)\s*=\s*([A-Za-z]+)/g; let m; while ((m = re.exec(h.value)) !== null) out.push(m[1].toUpperCase() + '=' + m[2].toLowerCase()); } return [...new Set(out)]; }
偽の結果が混ざる例
受信サーバ mail.example.org が付けた本物の結果(fail)が一番上にあり、送信者が自分で書き込んだ偽の結果(pass)が Received の下にある、という例を作る。
// 信じるのは「自分の authserv-id」で、最初の Received より上にあるものだけ functiontrusted(headers, myId) { const res = []; for (const h of headers) { const n = h.name.toLowerCase(); if (n === 'received') break; if (n !== 'authentication-results') continue; const id = h.value.split(';')[0].trim().split(/\s+/)[0].toLowerCase(); if (id === myId) res.push(h.value.replace(/\s+/g, ' ')); } return res; } console.log('trusted:', trusted(headers, 'mail.example.org'));
const lines = [ 'from a by b with ESMTP id 1; Tue, 1 Dec 2026 23:10:05 +0900', 'from a by b with ESMTP id 1; Tue, 1 Dec 2026 23:10:05 +0900 (JST)', 'from a by b with ESMTP id 1; Tue, 1 Dec 2026 14:10:05 -0000', 'from a by b with ESMTP id 1; Tue, 1 Dec 2026 23:10:05 JST', 'from a by b with ESMTP id 1; Tue, 1 Dec 26 23:10:05 +0900', 'from a by b with ESMTP id 1; 1 Dec 2026 23:10:05 +0900', 'from a by b with ESMTP id 1; Tue, 1 Dec 2026 23:10:05 +0900 (x; y)', 'from a by b with ESMTP id 1', ]; for (const v of lines) { const d = receivedDate(v); console.log(v.slice(v.indexOf(';') + 1).trim().padEnd(40), '->', d ? d.toISOString() : null); }
1 2 3 4 5 6 7 8 9
$ node dates.mjs Tue, 1 Dec 2026 23:10:05 +0900 -> 2026-12-01T14:10:05.000Z Tue, 1 Dec 2026 23:10:05 +0900 (JST) -> 2026-12-01T14:10:05.000Z Tue, 1 Dec 2026 14:10:05 -0000 -> 2026-12-01T14:10:05.000Z Tue, 1 Dec 2026 23:10:05 JST -> null Tue, 1 Dec 26 23:10:05 +0900 -> 2026-12-01T14:10:05.000Z 1 Dec 2026 23:10:05 +0900 -> 2026-12-01T14:10:05.000Z Tue, 1 Dec 2026 23:10:05 +0900 (x; y) -> null from a by b with ESMTP id 1 -> null
+0900 (JST) のように JST がコメントにあるだけなら、コメントを取り除くので読める。
時間帯を JST だけで書くと、Node.js の Date は読めず null になった(ツールでは「日時を読めません」と出る)。EST なら読める。