
我有一個使用 postfix 的相當簡單的電子郵件設定。在我的房子裡,運行在樹莓派上,我的路由器將所有連接埠轉發到該樹莓派。我有一個可以看到傳入郵件的 postfix 實例。我的電子郵件網域 (hartley-consultants.com) 的 MX 記錄指向此(外部)IP 位址。儘管它很少更改,但它可能會阻止外發郵件,因此我在雲端中的虛擬實例上有第二台伺服器,具有自己的專用 IP 位址。它還運行 postfix,並且還具有指向其 IP 位址的 hartley-consultants.com 的 MX 記錄。從我的家庭實例發出的所有郵件都透過該雲端伺服器路由。這種方式已經設定了很長一段時間(至少 5 年)。
我的 hartley-consultants.com dns 伺服器也有一個包含內容的 TXT 記錄v=spf1 mx -all
大約一個月前,我突然開始收到這樣的拒絕
This is the mail system at host asgard.hartley-consultants.com.
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
<[email protected]>: host
gmail-smtp-in.l.google.com[2a00:1450:400c:c1b::1a] said: 550-5.7.26 This
message fails to pass SPF checks for an SPF record with a hard 550-5.7.26
fail policy (-all). To best protect our users from spam and 550-5.7.26
phishing, the message has been blocked. Please visit 550-5.7.26
https://support.google.com/mail/answer/81126#authentication for more 550
5.7.26 information. k13-20020a5d66cd000000b002185e450efbsi9129616wrw.664 -
gsmtp (in reply to end of DATA command)
由 postfix 新增的此訊息的標頭的一部分是
Reporting-MTA: dns; asgard.hartley-consultants.com
X-Postfix-Queue-ID: 68A463A2807
X-Postfix-Sender: rfc822; [email protected]
Arrival-Date: Mon, 13 Jun 2022 21:49:42 +0100 (BST)
Final-Recipient: rfc822; [email protected]
Original-Recipient: rfc822;[email protected]
Action: failed
Status: 5.7.26
Remote-MTA: dns; gmail-smtp-in.l.google.com
Diagnostic-Code: smtp; 550-5.7.26 This message fails to pass SPF checks for an
SPF record with a hard 550-5.7.26 fail policy (-all). To best protect our
users from spam and 550-5.7.26 phishing, the message has been blocked.
Please visit 550-5.7.26
https://support.google.com/mail/answer/81126#authentication for more 550
5.7.26 information. k13-20020a5d66cd000000b002185e450efbsi9129616wrw.664 -
gsmtp
由於我現在已經退休了,這個電子郵件網域每月只發送幾封電子郵件,所以我需要修復它,但並不緊急。但是我去了谷歌幫助,它沒有給出任何我做錯了什麼的想法
這裡有人可以解釋一下谷歌認為什麼是錯誤的以及我需要做什麼來解決這個問題。
答案1
我想問題的答案大概就在於:
gmail-smtp-in.l.google.com[2a00:1450:400c:c1b::1a] said:
這表示您正在透過 IPv6 與 gmail 通信,但 MX 記錄中的主機在 DNS 中只有 IPv4 位址,因此您的 SPF 記錄將涵蓋所有這些位址,並遵循 MX 記錄。
答案2
hartley-consultants.com 的 SPF 記錄必須包含您傳送電子郵件的主機的 IP 位址。
Google 抱怨您傳送的 IP 位址未經授權。 (我在您的問題中沒有看到 IP 位址,因此無法驗證。)
我正在查看您的網域的 SPF 記錄,發現有兩個 IP 位址已獲得授權:
$ spftrace hartley-consultants.com
hartley-consultants.com
│ "v=spf1 mx -all"
├── mx → hartley-consultants.com (lookups: 1/10, nested: 2/10)
│ ├── mail.hartley-consultants.com
│ │ └── 94.173.170.110
│ └── asgard.hartley-consultants.com
│ └── 213.138.108.48
│ not-match
└── all match result=fail
fail
請確保在 SPF 原則中包含您發送郵件的 IP 位址。例如,您可以將特定的 IPv4 位址新增至目前的 SPF 原則:"v=spf1 mx ip4:11.22.33.44 -all"