Postfix 利用用户别名自动转发邮件

根据需求发送到邮箱service@test.com邮件转发到kf@test.com,并且发送到邮箱kf@test.com也能收到邮件

添加一个本地用户kf

kf:x:2011:2011::/var/spool/postfix/kf:/bin/bash

本地linux系统中有个用户service,为它设置一个别名,是kf

root@linux:mail#vim /etc/aliases

service: kf

还必须编辑/etc/postfix/main.cf文件

alias_maps = hash:/etc/aliases -->用来指定含有用户别名定义的文件路径,alias_database用来指定别名表数据库文件路径.

alias_database = hash:/etc/aliases -->用来指定别名表数据库文件路径.

注意配置文件中等号前后一定要有空格.

修改完配置文件后要使其生效,使用下面的命令

root@linux:mail# postalias /etc/aliases

root@linux:mail# postfix reload

postfix/postfix-script: refreshing the Postfix mail system

postalias命令用来将文件/etc/aliases生成postfix可以读取的数据库文件 /etc/aliases.db

下面我从163邮箱发送邮件到kf@test.com测试

root@linux:mail# pwd
/var/spool/mail
root@linux:mail# tail -f kf

From: dave <davemail163@163.com>
To: "kf@61.com" <kf@test.com>
Subject: test
X-Priority: 3
X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build
 20121107(20462.5035.5036) Copyright (c) 2002-2012 163com
X-CM-CTRLDATA: b1dKUWZvb3Rlcl9odG09ODY6ODE=
Content-Type: multipart/alternative;
 boundary="----=_Part_207345_818730686.1354877240624"
MIME-Version: 1.0
Message-ID: <42bc7ca5.dc84.13b74fa0530.Coremail.hechenmail163@163.com>
X-CM-TRANSID:icGowEDJK0I5ycFQ5MQCAA--.2475W
X-CM-SenderInfo: xkhfxvpqpdxzqrwtqiywtou0bp/1tbisBd+EE9o4ByE7QABs6
X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==

------=_Part_207345_818730686.1354877240624
Content-Type: text/plain; charset=GBK
Content-Transfer-Encoding: 7bit

test
------=_Part_207345_818730686.1354877240624
Content-Type: text/html; charset=GBK
Content-Transfer-Encoding: 7bit

<div>test</div><br><br><span title="neteasefooter"><span></span></span>
------=_Part_207345_818730686.1354877240624--

下面我从163邮箱发送邮件到service@test.com测试

root@linux:mail# pwd
/var/spool/mail
root@linux:mail# tail -f kf

From: dave <davemail163@163.com>
To: "service@61.com" <service@test.com>
Subject: aaaaaaaaaaaa
X-Priority: 3
X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build
 20121107(20462.5035.5036) Copyright (c) 2002-2012 163com
X-CM-CTRLDATA: /BRoT2Zvb3Rlcl9odG09OTY6ODE=
Content-Type: multipart/alternative;
 boundary="----=_Part_208943_889274004.1354878154594"
MIME-Version: 1.0
Message-ID: <450a4fa3.de38.13b7507f763.Coremail.hechenmail163@163.com>
X-CM-TRANSID:icGowEDpS0LKzMFQXMcCAA--.16656W
X-CM-SenderInfo: xkhfxvpqpdxzqrwtqiywtou0bp/1tbisBd+EE9o4ByE7QADs4
X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==

------=_Part_208943_889274004.1354878154594
Content-Type: text/plain; charset=GBK
Content-Transfer-Encoding: 7bit

aaaaaaaaaaaaaa
------=_Part_208943_889274004.1354878154594
Content-Type: text/html; charset=GBK
Content-Transfer-Encoding: 7bit

<div>aaaaaaaaaaaaaa</div><br><br><span title="neteasefooter"><span></span></span>
------=_Part_208943_889274004.1354878154594--

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/18fc652ebd9635d472cd2c13a47ae589.html