1

我正在从我的 Rails 应用程序发送邮件,但由于某种原因,我从未让 SPF 通过,它总是说失败或中立。

我已经设置了正向和反向 DNS(我认为是正确的)。我按照这里的指南无济于事。好消息是我的邮件不会成为垃圾邮件,但这对我来说还不够,我希望 SPF 通过。如果有人可以帮助我,将不胜感激。

我将主机名设置为mail.example.com. 我将反向 DNS 设置为相同。但是,当我发送邮件时,我希望它来自 help@example.com,而不是来自 help@mail.example.com。当我从 help@mail.example.com 发送电子邮件时,我得到一个中性的 SPF,但是当我将其更改为 help@example.com 时,它失败了。我理解的方式是,如果它仍然来自 FQDN,它应该通过,但它没有。

这些是我的 DNS 记录:

A = mail xxx.xxx.xxx.xxx
A = example. xxx.xxx.xxx.xxx
A = www xxx.xxx.xxx.xxx
MX = example. mailstore1.secureserver.net.
MX = example. smtp.secureserver.net.
MX = example. mail.example.com.
TXT = v=spf1 mx include:mail.example.com -all.

前 2 条 MX 记录来自 godaddy,但我使用 slicehost 托管该站点。另外,我有一些 CNAME 和 NS 记录,我认为它们没有帮助,但我会提到它们以防万一。

我在 Ubuntu 和 rails 3 上使用 postfix。

有任何想法吗?

更新: 这是我的一封失败邮件的标题

Delivered-To: myemail@gmail.com
Received: by 10.229.49.65 with SMTP id u1cs60507qcf;
        Mon, 12 Dec 2011 19:20:11 -0800 (PST)
Received: by 10.42.150.135 with SMTP id a7mr13973149icw.53.1323746409644;
        Mon, 12 Dec 2011 19:20:09 -0800 (PST)
Return-Path: <help@example.com>
Received: from mail.example.com ([xxx.xxx.xxx.xxx])
        by mx.google.com with ESMTP id y15si2866827ibk.138.2011.12.12.19.20.09;
        Mon, 12 Dec 2011 19:20:09 -0800 (PST)
Received-SPF: fail (google.com: domain of help@example.com does not designate xxx.xxx.xxx.xxx as permitted sender) client-ip=xxx.xxx.xxx.xxx;
Authentication-Results: mx.google.com; spf=hardfail (google.com: domain of help@example.com does not designate xxx.xxx.xxx.xxx as permitted sender) smtp.mail=help@example.com
Received: from localhost.localdomain (localhost [127.0.0.1])
    by mail.example.com (Postfix) with ESMTP id B6BB31C1F5D
    for <myemail@gmail.com>; Tue, 13 Dec 2011 03:20:08 +0000 (UTC)
Date: Tue, 13 Dec 2011 03:20:08 +0000
From: Example <help@example.com>
To: myemail@gmail.com
Message-ID: <4ee6c468a8150_7e4e4ea930773a1@mail.example.com.mail>
Subject: Password Reset
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

解决方案: 在 spf 记录周围加上引号,我的现在看起来像这样:

TXT = "v=spf1 mx include:mail.example.com -all"
4

1 回答 1

3

基于评论
的总结:引号在 TXT 记录的内容中很重要。空格算作分隔符。我遇到了一个 DNS 用户界面,其中草率地输入 v=spf1 -all(请注意缺少引号)导致两个原子“v=spf1”“-all”而不是单个原子“v=spf1 -all”。只有后者会起作用。

你的 SPF 记录搞砸了。“包括”是一个重定向。您是说 example.com 的 SPF 记录是 mail.example.com 的 SPF 记录,根据您的问题,我猜这不是您想要的。您应该在问题中包含所有相关的 DNS 信息(MX、A、TXT、SPF)。就像是:

例子.com。IN TXT "v=spf1 包括:example.net -all"
例子.net。在 TXT "v=spf1 mx -all"
于 2011-12-14T19:06:41.630 回答