2014-05-08

postfix僅允許特定信箱使用群組寄信

1,定义规范等级,名称分别为local_onlylocal_only1,修改main.cf(注:红色的代表新增加的)
[root@mail postfix]# vi main.cf

#youshengtao 2010-10-12
smtpd_restriction_classes = local_only, local_only1
local_only = check_recipient_access hash:/etc/postfix/plugin/plugin.list,reject
local_only1 = check_sender_access hash:/etc/postfix/plugin/plugin.users,reject

smtpd_recipient_restrictions = reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_non_fqdn_sender, reject_non_fqd
n_recipient, reject_unlisted_recipient, check_sender_access hash:/etc/postfix/plugin/plugin.users, check_sender_access hash:/etc/postfix/plugin/local_senders, check_recipient_access hash:/etc/postfix/plugin/local_recipients, permit_mynetworks, permit_sasl_authenticated, rejec
t_unauth_destination, reject_non_fqdn_helo_hostname, reject_invalid_helo_hostname, check_policy_service inet:127.0.0.1:10031



2,建立相关的目录,也可以不建目录,直接放在postifx目录下面,不过,为了以后维护方便,我还是建了一个目录。
[root@mail ~]# mkdir -p /etc/postfix/plugin
[root@mail ~]# cd /etc/postfix/plugin/

[root@mail plugin]# vi local_recipients
qtyg@ourgame.com local_only1

[root@mail plugin]# vi local_senders
wanglujing@ourgame.com local_only
renlina@ourgame.com    local_only
caiyanyan@ourgame.com  local_only
qinwen@ourgame.com     local_only
shiwanting@ourgame.com  local_only

[root@mail plugin]# vi plugin.list
qtyg@ourgame.com OK

[root@mail npc]# vi plugin.users
wanglujing@ourgame.com OK
renlina@ourgame.com    OK
caiyanyan@ourgame.com  OK
qinwen@ourgame.com     OK
shiwanting@ourgame.com OK


3,使用postmap将下列的文件转换成postfix可直接查询的格式。
postmap hash:/etc/postfix/plugin/plugin.list
postmap hash:/etc/postfix/plugin/plugin.users
postmap hash:/etc/postfix/plugin/local_senders
postmap hash:/etc/postfix/plugin/local_recipients


4,重载postfix后,邮件服务器正常工作,实现了我们需要的功能。
[root@mail npc]# service postfix reload
重新载入postfix:[确定]


參考來源:
http://chlotte.blog.51cto.com/318402/404764/