SPF (Sender Policy Framework) 是基於 DNS TXT 記錄的郵件發送方授權機制,旨在解決「發件人地址偽造」這一垃圾郵件核心難題。正確部署 SPF 能顯著提升域名郵件信譽,降低進垃圾箱概率。
example.com。example.com 的 DNS TXT 記錄獲取 SPF 策略。v=spf1 [mechanisms] [modifiers] [all]
| 機制 | 含義 | 範例 |
|---|---|---|
| ip4 / ip6 | 授權單個 IP 或 CIDR 网段 | ip4:203.0.113.10, ip4:198.51.100.0/24 |
| a | 授權域名 A 記錄對應的 IP | a:mail.example.com |
| mx | 授權域名 MX 記錄指向的服務器 IP | mx |
| include | 引入第三方服務商 SPF 策略 | include:_spf.google.com |
| exists | 動態查詢 (進階) | exists:%{i}._spf.example.com |
+ Pass (預設,可省略)- Fail (明確拒絕,建議生產環境最終用 -all)~ SoftFail (疑似偽造,標記但不拒,調試期適用)? Neutral (不表態)v=spf1 ip4:203.0.113.0/24 include:_spf.google.com include:spf.mandrillapp.com -all
-all 明確拒絕其他來源v=spf1 include:_spf.google.com include:sendgrid.net -all
Received-SPF: pass / Authentication-Results: spf=passmail.example.com 不會自動繼承 example.com 的 SPF,必須在子域添加 TXT 記錄。~all 觀察 1-2 週,確認無誤報後改 -all。