给域名添加SPF记录

 
独立域名博客在收到主机寄过来的邮件时,邮件头会经常显示如下两行:
Received-SPF: neutral (google.com: 72.47.192.112 is neither permitted nor denied by best guess record for domain of wordpress@your_domain.com) client-ip=72.47.192.112;
Received-SPF: fail (google.com: domain of wordpress@your_domain.com does not designate 72.47.192.112 as permitted sender) client-ip=72.47.192.112;
Authentication-Results: mx.google.com; spf=hardfail (google.com: domain of wordpress@your_domain.com does not designate 72.47.192.112 as permitted sender) smtp.mail=wordpress@your_domain.com
Received-SPF: softfail (google.com: domain of transitioning wordpress@your_domain.com does not designate 72.47.192.112 as permitted sender) client-ip=72.47.192.112;
Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning wordpress@your_domain.com does not designate 72.47.192.112 as permitted sender) smtp.mail=wordpress@your_domain.com
对一个完美主义者来说,出现“Fail”是不可接受的,这种邮件被Gmail扔进Spam的几率比较大哦。这是你域名的SPF记录没配置好出现验证失败的缘故,那什么是SPF呢?
由于同一个域名可能透过多台的mail server或是ISP寄信,通过IP地址来反向解析看是否为伪造信件的方式就不够用了(我们也经常可以收到发件人是自己的垃圾邮件)。因此就有域名验证的观念出来了,共包括domain key和SPF这两大类,都必须在网域名称的DNS记录中加入一笔记录。
SPF(或是Sender ID)是Sender Policy Framework的缩写。当你定义了你域名的SPF记录后,接收邮件方会根据你的SPF记录来判断连接过来的IP地址是否被包含在SPF记录里面,如果在,则认为是一封正确的邮件,否则则认为是一封伪造的邮件。现在绝大部份反垃圾邮件系统都支持SPF过滤,这种过滤一般不会有误判,除非是邮件系统管理员自己把SPF记录配置错误或遗漏.
至于domain key则是由Yahoo所提出的。必需配合软件和加密技术,比较麻烦。目前使用的也不多。 Google目前所谓的支援domainkey也只是在寄信的时候加入,免得被yahoo退信,本身并没有要求寄件者要有domainkey。
正确设置后邮件头一般显示如下:
Received-SPF: pass (google.com: domain of wordpress@your_domain.com designates 72.47.192.112 as permitted sender) client-ip=72.47.192.112;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of wordpress@your_domain.com designates 72.47.192.112 as permitted sender) smtp.mail=wordpress@your_domain.com
关于SPF是否有设定的必要?一般认为有加上SPF比较好,怕万一碰到哪个收件服务器有采用SenderID机制来过滤信件的话就有用处了。
如何增加SPF记录,非常简单,在DNS里面添加TXT记录即可,可以使用下面两个SPF生成检查工具:
http://www.microsoft.com/mscorp/safety/content/technologies/senderid/wizard/default.aspx
http://old.openspf.org/wizard.html
a 你域名的A记录,一般选择yes,因为他有可能发出邮件,比如我上面提到的Wordpress的回信。
mx 一般也是yes,MX服务器会有退信等。
ptr 选择no,官方建议的。
inlude 如果有可能通过一个isp来发信,isp有自己的SPF记录,则填入这个isp的域名。比如你使用Google Apps,应该增加include:google.com记录,因为你的邮件时从Google服务器发出去的。
ip4: 你还有没有其他的ip发信?可能你的smtp服务器是独立出来的,那么就填入你的IP地址或者网段。
~all: 意思是除了上面的,其他的都不认可。当然是yes了。
再检查下,进入cmd(以Google.com为例):
C:\Documents and Settings\>nslookup
Default Server: resolver1.opendns.com
Address: 208.67.222.222>
> set type=txt
>
> google.com
Server: resolver1.opendns.com
Address: 208.67.222.222
Non-authoritative answer:
google.com text =
“v=spf1 include:_netblocks.google.com ~all”
>
> _netblocks.google.com
Server: resolver1.opendns.com
Address: 208.67.222.222
Non-authoritative answer:
_netblocks.google.com text =
“v=spf1 ip4:216.239.32.0/19 ip4:64.233.160.0/
2.14.192.0/18 ip4:209.85.128.0/17 ip4:66.102.0.0/20 i
0.0/20 ip4:207.126.144.0/20 ?all”
>
>behindgfw.com
Server: resolver1.opendns.com
Address: 208.67.222.222
Non-authoritative answer:
behindgfw.com   text =
“v=spf1 a a:fwolf.com mx include:google.com ~all”
ok,都设置好了,给check-auth@verifier.port25.com发封邮件,很快会有回信告诉你设置是否正确。或者在 http://69.56.15.194/找到一个形如XXXX@69.56.15.194的邮箱地址,发封邮件,点击“view sample”就可以看见你的检测结果了。这两种方式都会返回详细的SPF check、DomainKeys check、DKIM check、Sender-ID check结果。
至于那些域名注册商支持添加SPF记录,可以在如下网址检查:
http://www.kitterman.com/spf/txt.html