使用postfix发送邮件,需要你对本身配置做些修正,另外,也需要你设置相应的DNS,否则发送邮件会容易当做垃圾邮件。
我们做几个步骤来看看收信的影响:
1 安装后不设置
2 设置hostname和domain
3 设置MX记录
4 设置SPF
以下说明的信息为了去除隐私信息,做过一些名称修改:
= 1 没有任何配置 =
Delivered-To: your-email@gmail.com
Received: by 10.114.181.20 with SMTP id d20cs1238waf;
Mon, 4 Jan 2010 17:33:21 -0800 (PST)
Received: by 10.141.90.17 with SMTP id s17mr7576023rvl.196.1262655201126;
Mon, 04 Jan 2010 17:33:21 -0800 (PST)
Return-Path:
Received: from localhost.localdomain ([219.232.1.2])
by mx.google.com with ESMTP id 20si58728702pwj.8.2010.01.04.17.33.18;
Mon, 04 Jan 2010 17:33:19 -0800 (PST)
Received-SPF: neutral (google.com: 219.232.1.2 is neither permitted nor denied by best guess record for domain of root@localhost.localdomain) client-ip=219.232.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 219.232.1.2 is neither permitted nor denied by best guess record for domain of root@localhost.localdomain) smtp.mail=root@localhost.localdomain
Received: by localhost.localdomain (Postfix, from userid 0)
id 7BF5120DF2C; Mon, 4 Jan 2010 21:33:09 -0500 (EST)
To: your-email@gmail.com
Subject: test in 95
Message-Id:
Date: Mon, 4 Jan 2010 21:33:09 -0500 (EST)
From: root@localhost.localdomain (root)
test
我们看到,发信人是root@localhost.localdomain,明显不对的
回复邮件也肯定收不到,我们至少需要用户能够回复,当然,除非你不想。
= 2 设置hostname和domain =
postconf -e "myhostname=chinastor.cn"
postconf -e "mydomain=mail.chinastor.cn"
postfix reload
postfix里面修改参数可以用以上的方式,检查参数
可以是 postconf myhostname
Delivered-To: your-email@gmail.com
Received: by 10.114.181.20 with SMTP id d20cs2044waf;
Mon, 4 Jan 2010 17:52:44 -0800 (PST)
Received: by 10.142.2.14 with SMTP id 14mr7796472wfb.93.1262656364099;
Mon, 04 Jan 2010 17:52:44 -0800 (PST)
Return-Path:
Received: from chinastor.cn ([219.232.1.2])
by mx.google.com with ESMTP id 4si15052142pwj.24.2010.01.04.17.52.43;
Mon, 04 Jan 2010 17:52:43 -0800 (PST)
Received-SPF: neutral (google.com: 219.232.1.2 is neither permitted nor denied by best guess record for domain of root@chinastor.cn) client-ip=219.232.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 219.232.1.2 is neither permitted nor denied by best guess record for domain of root@chinastor.cn) smtp.mail=root@chinastor.cn
Received: by chinastor.cn (Postfix, from userid 0)
id 9AB3420DF2F; Mon, 4 Jan 2010 21:52:34 -0500 (EST)
To: your-email@gmail.com
Subject: test after modify myhostname and mydomain
Message-Id:
Date: Mon, 4 Jan 2010 21:52:34 -0500 (EST)
From: root@chinastor.cn (root)
test
看到了吧?
发信人是 root@chinastor.cn 了,这用户至少知道是谁发的
如果用户回复邮件,那就会发到chinastor.cn指定的邮件服务器,这个是通过DNS查询判断发送到哪里的。
下面来修改DNS:
= 3 设置DNS =
添加一条MX记录:@ MX mail.chinastor.cn.
再添加一条A记录: mail A your_IP
一般建议不直接指向IP
收到的邮件无变化,忽略邮件说明。
= 4 设置SPF =
细心的话,可以看的出来,gmail有一段信息:
Received-SPF: neutral (google.com: 219.232.1.2 is neither permitted nor denied by best guess record for domain of root@chinastor.cn) client-ip=219.232.1.2;
Authentication-Results: mx.google.com; spf=neutral (google.com: 219.232.1.2 is neither permitted nor denied by best guess record for domain of root@chinastor.cn) smtp.mail=root@chinastor.cn
SPF是什么?
SPF 是发送方策略框架
(Sender Policy Framework) 的缩写,一种以IP(互联网协定)地址认证电子邮件寄件人身份的技术,是非常高效的垃圾邮件解决方案,旨在应对垃圾邮件中的一个特别问题——发送方假冒问题。当用户定义了他的域名SPF记录之后,接收邮件方会根据该用户的SPF记录来确定连接过来的IP地址是否被包含在SPF记录里面,如果在,则认为是一封正确的邮件,否则则认为是一封伪造的邮件。因此,那些发信人伪造域名的垃圾邮件在SPF的火眼金睛下再也无法隐藏,企业邮箱就可以有效地避免此类垃圾邮件。
设置SPF可以有简单的方法:
http://old.openspf.org/wizard.html
DNS添加一条TXT记录:
v=spf1 mx a:mail.chinastor.cn ~all
邮件会不一样:
Delivered-To: your-email@gmail.com
Received: by 10.114.181.20 with SMTP id d20cs2325waf;
Mon, 4 Jan 2010 17:58:31 -0800 (PST)
Received: by 10.141.100.8 with SMTP id c8mr13115112rvm.201.1262656711500;
Mon, 04 Jan 2010 17:58:31 -0800 (PST)
Return-Path:
Received: from chinastor.cn ([219.232.1.2])
by mx.google.com with ESMTP id 35si27159111pxi.23.2010.01.04.17.58.30;
Mon, 04 Jan 2010 17:58:30 -0800 (PST)
Received-SPF: pass (google.com: domain of root@chinastor.cn designates 219.232.1.2 as permitted sender) client-ip=219.232.1.2;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of root@chinastor.cn designates 219.232.1.2 as permitted sender) smtp.mail=root@chinastor.cn
Received: by chinastor.cn (Postfix, from userid 0)
id 8C66C20DF2F; Mon, 4 Jan 2010 21:58:21 -0500 (EST)
To: your-email@gmail.com
Subject: test after setting SPF
Message-Id:
Date: Mon, 4 Jan 2010 21:58:21 -0500 (EST)
From: root@chinastor.cn (root)
test
也就是通过了SPF检查,这样一般的邮件服务器都不会认为你的是垃圾邮件,除非很多人举报你。
当然,能够设置PTR记录就更加完美了。