Postfix用户收发控制

实践过程:

smtpd_restriction_classes = insiders_only
insiders_only = check_sender_access hash:/etc/postfix/insiders,reject 

##开头绝不能有空格、Tab之类,否则连接不到SMTP服务器。

smtpd_recipient_restrictions =
        check_recipient_access hash:/etc/postfix/protected_list,

#/etc/postfix/protected_list:  (要通过postmap hash:/etc/postfix/protected_list生成.db文件才有效)

all@domain.com insiders_only     ##只允许/etc/postfix/insiders列表中的规则用户生效

#/etc/postfix/insiders:

erik@domain.com OK    ##允许erik

xxx@domain.com  discard   ##不发送到发件人及收件人

domain.com   OK      ##内网用户允许

以上就实现了控制只有授权用户才可以发邮件到all@domain.com了。

以下是参考资料:

对于限制的用户,其实只能对其外发(或者说rcpt to)做限制,而对于任意来信人给其发来的email则没有限制能力,真正的内部收发邮件用户,应该是只允许它和指定的内部域名(用户)联系,对于发向任何外部邮件域,或任意外部邮件域发来的邮件,都是禁止的。

这里给出一个配置,仅供大家参考。

配置方法:

1)在main.cf里定义如下的smtpd_restriction_classes:

 # restrictions
smtpd_restriction_classes = local_out_only local_in_only
local_out_only = check_recipient_access hash:/etc/postfix/local_domains, reject
local_in_only = check_sender_access hash:/etc/postfix/local_domains, reject

 

2)将main.cf里的smtpd_recipient_restrctions定义为:

 smtpd_recipient_restrictions =
        check_sender_access hash:/etc/postfix/local_out_senders
        check_recipient_access hash:/etc/postfix/local_in_senders
        permit_mynetworks,
        permit_sasl_authenticated,
        reject_non_fqdn_hostname,
        reject_non_fqdn_sender,
        reject_non_fqdn_recipient,
        reject_unauth_destination,
        reject_unauth_pipelining,
        reject_invalid_hostname,

3)编辑/etc/postfix/local_in_senders:

 foo@extmail.org local_in_only
bar@extmail.org local_in_only
4)编辑/etc/postifx/local_out_senders:
QUOTE:
foo@extmail.org local_out_only
bar@extmail.org local_out_only
 

 

5)编辑/etc/postfix/local_domains:

 extmail.org         OK
all@extmail.org         reject


6)为3,4,5建立对应的hash文件:

# postmap hash:/etc/postfix/local_in_senders  ##此处postmap命令要加上路径,或在程序所在目录下运行
# postmap hash:/etc/postfix/local_out_senders
# postmap hash:/etc/postfix/local_domains

这样就定义了extmail.org域名里两个用户foo和bar,只允许和internal.foo.com和internel.bar.com 两个内部域的用户来往邮件,对于外部的邮件则没有收或发的能力。如果外部邮件企图给这2个用户发送,则遇到如下错误:

 554 5.7.1 <foo@extmail.org>: Recipient address rejected: Access denied


如果这2个内部用户要给外部用户发email,将遇到如下错误:

 554 5.7.1 <bar@extmail.org>: Sender address rejected: Access denied


目前这样的配置就可以比较完整的实现内部用户的功能需求了。其实这种配置的方法和之前的帖子道理一样,关键得分清楚什么阶段,调用什么restrictions即可。


该文章转载自宋氏电脑 技术无忧:http://www.pc51.net/server/mail/2007-11-25/9815.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值