Postfix限制部分用户发送和接收外部邮件

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文件内容为:
  [email protected] local_only
local_recipients文件内容为:
  [email protected] 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 protected] local_only" >> /etc/postfix/local_senders
echo " [email protected] 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

你可能感兴趣的:(职场,休闲)