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

根据需求发送到邮箱[email protected]邮件转发到[email protected],并且发送到邮箱[email protected]也能收到邮件

添加一个本地用户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 <[email protected]>
To: "[email protected]" <[email protected]>
Subject: test
X-Priority: 3
X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build
 20121107(20462.5035.5036) Copyright (c) 2002-2012 www.mailtech.cn 163com
X-CM-CTRLDATA: b1dKUWZvb3Rlcl9odG09ODY6ODE=
Content-Type: multipart/alternative; 
	boundary="----=_Part_207345_818730686.1354877240624"
MIME-Version: 1.0
Message-ID: <[email protected]>
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 style="line-height:1.7;color:#000000;font-size:14px;font-family:arial">test</div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></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 <[email protected]>
To: "[email protected]" <[email protected]>
Subject: aaaaaaaaaaaa
X-Priority: 3
X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build
 20121107(20462.5035.5036) Copyright (c) 2002-2012 www.mailtech.cn 163com
X-CM-CTRLDATA: /BRoT2Zvb3Rlcl9odG09OTY6ODE=
Content-Type: multipart/alternative; 
	boundary="----=_Part_208943_889274004.1354878154594"
MIME-Version: 1.0
Message-ID: <[email protected]>
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 style="line-height:1.7;color:#000000;font-size:14px;font-family:arial">aaaaaaaaaaaaaa</div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>
------=_Part_208943_889274004.1354878154594--




你可能感兴趣的:(用户别名自动转发邮件)