增加对 return-path 和 SPF 记录的理解

Increasing understanding of return-path and SPF records

我有一个带有由第三方托管的 Web 表单的网站。我在使用他们的服务器 config/architecture 时遇到问题,想确认一些事情并显示我收到的邮件 header。

我知道我必须明确设置我的邮件通过我指定的外发邮件服务器和端口发送(这是为了邮件发送,如果不通过 SMTP 服务器发送则不会发送).

设置好SMTP服务器和端口后就是邮件header:

x-store-info:sbevkl2QZR7OXo7WID5ZcdV2tiiWGqTnhQzu7BHe69dd2ZvcRr0xBttv16txT0x/MHyyxbQQOWxD0k3WKrQDVl56gwTtl9T9YlQDKWZad3R7ZbliBL6BSfw52gpz37cwL/qGTahKP+U=
Authentication-Results: hotmail.com; spf=softfail (sender IP is 213.171.216.60) smtp.mailfrom=test@hotmail.co.uk; dkim=none header.d=hotmail.co.uk; x-hmca=fail header.id=test@hotmail.co.uk
X-SID-PRA: test@hotmail.co.uk
X-AUTH-Result: FAIL
X-SID-Result: FAIL
X-Message-Status: n:n
X-Message-Delivery: Vj0xLjE7dXM9MDtsPTA7YT0xO0Q9MTtHRD0xO1NDTD0y
X-Message-Info: NhFq/7gR1vSyCjVJ7Q2iIHhF9oW5eW+g+jrtzv+TwMhHX16XKDSEsIIxc1qXk1NO+AwFoToprpXBtEMxyoOvMnJSYUEEN4JngTWWsUg0/J3120nOI8GDZ8sF8m5iNGKuZt7Ds7svv3bOfUNBVLmpGlsbHUCNwXFNgry/rw0sWtsI0nyKa01KIdnxHDoLHp7GPP/klJGbBhJE2FLEW70tX5XZujwdcC9+R5m/pk5uo4uPxfmnwQK9yQ==
Received: from cust-smtp-auth1.fasthosts.net.uk ([213.171.216.60]) by BLU004-MC1F22.hotmail.com with Microsoft SMTPSVC(7.5.7601.23143);
     Mon, 28 Dec 2015 05:59:03 -0800
Received: from fun-booths.co.uk (unknown [88.208.252.229])
    by cust-smtp-auth1.fasthosts.net.uk (Postfix) with ESMTP id 923AF74021D
    for <c_qatest@hotmail.co.uk>; Mon, 28 Dec 2015 13:59:02 +0000 (GMT)
Date: Mon, 28 Dec 2015 13:59:02 +0000
To: c_qatest@hotmail.co.uk
From: "test@hotmail.co.uk" <test@hotmail.co.uk>
Subject: Fun Booths - Booking form
Message-ID: <918f36d31bf876f19ea6d9563c1ad348@fun-booths.co.uk>
X-Priority: 3
X-Mailer: PHPMailer 5.2.10 (https://github.com/PHPMailer/PHPMailer/)
Reply-To: test@hotmail.co.uk
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Return-Path: test@hotmail.co.uk
X-OriginalArrivalTime: 28 Dec 2015 13:59:03.0161 (UTC) FILETIME=[E8B5FE90:01D14177]

关注 Authentication-Results (sender IP is 213.171.216.60) 这绝对是正确的传出 SMTP 服务器。但是 spf 结果是 spf=softfail

经过一些研究,有人建议

The Return-Path header is empty. This means that during the SMTP conversation, the MAIL FROM command did not specify an email address where bounces are sent. It is the domain from this email address that SPF tests. If there is no email address, a softfail will result.

这是否指的是 Authentication-Results 中的 smtp.mailfrom 字段,在上面的示例中它被设置为值 test@hotmail.co.uk

我相信我已经完成了实施 SPF 所需的工作:

(1) 我已经在域的 DNS 区域中设置了 SPF 记录

v=spf1 a ip4:213.171.216.0/24 mx -all

这里出现了混乱。当其他人的邮件服务器收到一封声称来自该域的邮件时,那么

(2) 接收服务器可以检查邮件是否符合域的声明策略

例如hotmail的接收邮件服务器是如何检查的?因为如果我设置 hello@fun-booths.co.uk 的 Return-Path 那么这会导致 spf=pass。需要明确的是 www.fun-booths.co.uk 是正在使用的域。

x-store-info:J++/JTCzmObr++wNraA4Pa4f5Xd6uens6FBov4shFUrwGsQPla5CZKHNFpj4XdT2wfaqUtXggI++7RpfQIpooWW0Sp2ynYP894LLfhswpqbr+Di/ao+0Ofc9Btl/xdHLsTQXTk39KBE=
Authentication-Results: hotmail.com; spf=pass (sender IP is 213.171.216.60) smtp.mailfrom=hello@fun-booths.co.uk; dkim=none header.d=fun-booths.co.uk; x-hmca=pass header.id=hello@fun-booths.co.uk
X-SID-PRA: hello@fun-booths.co.uk
X-AUTH-Result: PASS
X-SID-Result: PASS
X-Message-Status: n:n
X-Message-Delivery: Vj0xLjE7dXM9MDtsPTE7YT0xO0Q9MTtHRD0xO1NDTD0w
X-Message-Info: NhFq/7gR1vTQzco4wDfDIuNexRCLt7KFLQW7EkmNLn/2YehuSC93bNZTp87n+KmseY8TwxSqCjOondyBGOJR9CRbKyT/FU2B2nhMw3SU8HjmnNyAmDcRFqxvARiDy1lMz5O7U5B61WNdLZsDb1vLPQ93l4XO90mQcjMfCI4SWr50rtHEJwK9Y/c2zDWf8jdVXEgQOyBm4pQwu9z7isJFvrHl9HRMGMcWeNHQVVCsFOoqJ8mhQItxPg==
Received: from cust-smtp-auth2.fasthosts.net.uk ([213.171.216.60]) by SNT004-MC2F7.hotmail.com with Microsoft SMTPSVC(7.5.7601.23143);
     Mon, 28 Dec 2015 06:05:27 -0800
Received: from fun-booths.co.uk (unknown [88.208.252.229])
    by cust-smtp-auth2.fasthosts.net.uk (Postfix) with ESMTP id 66414740221
    for <c_qatest@hotmail.co.uk>; Mon, 28 Dec 2015 14:05:26 +0000 (GMT)
Date: Mon, 28 Dec 2015 14:05:26 +0000
To: c_qatest@hotmail.co.uk
From: "hello@fun-booths.co.uk" <hello@fun-booths.co.uk>
Subject: Fun Booths - Booking form
Message-ID: <85119bedb602f9865290c2ea218315b4@fun-booths.co.uk>
X-Priority: 3
X-Mailer: PHPMailer 5.2.10 (https://github.com/PHPMailer/PHPMailer/)
Reply-To: test@hotmail.co.uk
X-Sender: hello@fun-booths.co.uk
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Return-Path: hello@fun-booths.co.uk
X-OriginalArrivalTime: 28 Dec 2015 14:05:27.0582 (UTC) FILETIME=[CDD7FBE0:01D14178]

这引出了我的最后一个问题 - Return-Path 是否必须设置为网站域 (www.fun-booths.co.uk 上的真实电子邮件地址? ), 或者邮件不会发送?

因为我已经设置了邮箱hello@fun-booths.co.uk,但是即使我删除了邮箱,这仍然会导致spf=pass。似乎换句话说,在域上没有真实的电子邮件地址,而只是将 Return-Path 设置为 hello@fun-booths.co.uk 而邮箱不存在将导致 spf=pass。应该是这样吗?

Return-Path 中设置的电子邮件 @fun-booths.co.uk 是否用于确定 SPF 检查的域?

最后在上面提到 SMTP 对话的引文中,MAIL FROM 命令是否引用 Authentication-Results 中的 smtp.mailfrom 字段?

SPF 检查始终由信封发件人 (MAIL FROM:) 完成 - smtp.mailfrom 在您的案例中。在第一封邮件中,您将 test@hotmail.co.uk 作为信封发件人,但您的服务器未在 hotmail.co.uk 的 SPF 记录中列出,并且由于该记录将 ~all 作为最后一种机制,您将获得 Softfail。

在第二封邮件中,信封发件人是 hello@fun-booths.co.uk,因此其中使用的是 fun-booths.co.uk 的 SPF 记录查看。

所以您应该使用 fun-booths.co.uk 地址作为您的信封发件人。

根据您从 Web 表单发送邮件的方式,有不同的方法来控制信封发件人,但可能 Return-Path 的值用作信封发件人。

信封发件人不必 mail-box SPF 就可以工作,因为 SPF 通常只查看地址的域部分,但如果邮件在此过程中的某处退回,退回邮件通常会发送到信封发件人,因此最好保留该地址的邮箱。