Postfix限制部分用户发送和接收外部邮件 [ 网站地图 ]

发表于:2009-10-12 浏览:605 作者: 来源:互联网

关键字:POSTFIX,邮件,用户

描述:1.編輯main.cf,在最後添加smtpd_restriction_classes=local_only,local_only1local_only=check_recipient_accesshash:/etc/postfix/local_domains,rejectlocal_only1=check_sender_accesshash:/etc/postfi

1.編輯main.cf,在最後添加
smtpd_restriction_classes = local_only, local_only1
local_only = check_recipient_access hash:/etc/postfix/local_domains,reject
local_only1 = check_sender_access hash:/etc/postfix/local_domains,reject
smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/local_senders,
check_recipient_access hash:/etc/postfix/local_recipients,
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unauth_destination,
reject_unauth_pipelining,
reject_rhsbl_sender,
reject_unknown_sender_domain,
reject_invalid_hostname
注1:從第5行開始前面空一格.
2) 新增local-domains  ,  local_senders  ,  local_recipients三个文件
local_domains文件内容为:
  domain.com OK
  192.168.0.1 OK
local_senders文件内容为:
  kently@domain.com local_only
local_recipients文件内容为:
  kently@domain.com local_only1
3) postmap hash:/etc/postfix/local_domains
   postmap hash:/etc/postfix/local_senders
   postmap hash:/etc/postfix/local_recipients
4) postfix reload




注2:以后需要经常添加mial地址的时候可以使用以下脚本

#sh
email=kently
#要修改Email,就只用修改这个变量值。
echo "$email@AA.com local_only" >> /etc/postfix/local_senders
echo "$email@AA.com local_only1" >> /etc/postfix/local_recipients
#创建文件
postmap hash:/etc/postfix/local_domains
postmap hash:/etc/postfix/local_senders
postmap hash:/etc/postfix/local_recipients
#postfix查询数据库
postfix reload
#加载配置
注3:删除
sed ‘s/dd@aa/456/g‘ /etc/postfix/local_senders > /etc/postfix/local_senders.new
mv -f /etc/postfix/local_senders.new /etc/postfix/local_senders
sed ‘s/dd@aa/456/g‘ /etc/postfix/local_recipients > /etc/postfix/local_recipients.new
mv -f /etc/postfix/local_recipients.new /etc/postfix/local_recipients
postmap hash:/etc/postfix/local_domains
postmap hash:/etc/postfix/local_senders
postmap hash:/etc/postfix/local_recipients
postfix reload

站长资讯网 做中国最丰富的资讯网站 沪ICP备05004089号