设置SPF防止被当作垃圾邮件的方法

在发送每周推广邮件的时候,在收到主机寄过来的邮件时,在谷歌的header邮件头信息会经常显示如下两行:


Received-SPF: neutral (google.com: 12.23.34.45 is neither permitted nor denied by best guess record for domain of noreply@your_domain.com) client-ip=12.23.34.45;


Received-SPF: fail (google.com: domain of noreply@your_domain.com does not designate 12.23.34.45 as permitted sender) client-ip=12.23.34.45;

Authentication-Results: mx.google.com; spf=hardfail (google.com: domain of noreply@your_domain.com does not designate 12.23.34.45 as permitted sender) smtp.mail=noreply@your_domain.com

Received-SPF: softfail (google.com: domain of transitioning noreply@your_domain.com does not designate 12.23.34.45 as permitted sender) client-ip=12.23.34.45;

Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning noreply@your_domain.com does not designate 12.23.34.45 as permitted sender) smtp.mail=noreply@your_domain.com

这些都是不正常的邮件头信息,表示spf记录查询失败或没有设置spf记录。这样的邮件虽然也能够收到,但很有可能会被gmail判成垃圾邮件spam,不光gmail,qq和163其实也是检查spf记录的,只是没有加在邮件的header中展示出来。所以为了能在各大邮箱服务商那里正常接收,而不被误判为垃圾邮件,就需要正确设置好spf记录。

SPF(或是Sender ID)是Sender Policy Framework的缩写。当你定义了你域名的SPF记录后,接收邮件方会根据你的SPF记录来判断连接过来的IP地址是否被包含在SPF记录里面,如果在,则认为是一封正确的邮件,否则则认为是一封伪造的邮件。现在绝大部份反垃圾邮件系统都支持SPF过滤,这种过滤一般不会有误判,除非是邮件系统管理员自己把SPF记录配置错误或遗漏.

如何查看spf记录

如查看当当网的邮件服务器的spf记录,输入以下命令:

dig -t txt sendemail.dangdang.com

显示的信息为:

sendemail.dangdang.com. 3600 IN TXT "v=spf1 a:sendemail.dangdang.com -all"

在正确设置spf记录后,gmail的header头信息就会是如下:

Received-SPF: pass (google.com: domain of noreply@your_domain.com designates 12.23.34.45 as permitted sender) client-ip=12.23.34.45;

Authentication-Results: mx.google.com; spf=pass (google.com: domain of noreply@your_domain.com designates 12.23.34.45 as permitted sender) smtp.mail=noreply@your_domain.com

如何设置spf记录

我使用的是dnspod的域名解析服务,有详细的教程指导设置spf记录。点击这里查看教程。

需要注意的是,你首先要设置一个这个域名的A记录和mx记录。然后按照如下教程操作即可。


怎样添加TXT记录

1、什么情况下会用到TXT记录?

[如果希望对域名进行标识和说明,可以使用TXT记录,绝大多数的TXT记录是用来做SPF记录(反垃圾邮件)]

2、TXT记录的添加方式

A.主机记录处填子域名(比如需要添加www.123.com的TXT记录,只需要在主机记录处填写www即可;如果只是想添加123.com的TXT记录,主机记录直接留空,系统会自动填一个“@”到输入框内)

B.记录类型为TXT

C.线路类型(默认为必填项,否则会导致部分用户无法解析;TXT记录不需要智能解析,直接默认即可)

D.记录值并没有固定的格式,不过大部分时间,TXT记录是用来做SPF反垃圾邮件的

最典型的spf格式的txt记录例子为“v=spf1 a mx ~all”,表示只有这个域名的a记录和mx记录中的ip地址有权限使用这个域名发送邮件

E.MX优先级不需要填写

F.TTL不需要填写,添加时系统会自动生成,默认为600秒

(TTL为缓存时间,数值越小,修改记录生效时间越快)

如:需要使用[email protected]发送邮件

首先设置一个mailtest.mydomain.com的A记录。

然后设置一个mailtest.mydomain.com的MX记录。

最后设置mailtest.mydomain.com的txt记录,在记录值这个段填上"v=spf1 a mx ~all",不要把双引号也copy进去。


设置好后,可使用命令dig -t txt查看是否生效。


分享到:


相關文章: