2015年10月13日 星期二

postfix 限制指定帳號只能寄信至指定郵箱

欲限制指定帳號只可寄信至指定郵箱,其餘拒絕,例如希望使用者帳號只在公司內部使用,不可寄信至外部郵箱,可依以下設定。

1.修改postfix的設定檔main.cf

  • 在"smtpd_sender_restrictions ="設定值內加入如下設定:
          check_sender_access hash:/etc/postfix/check_sender
  • 新增限制類別
          smtpd_restriction_classes = local_only
          local_only = check_recipient_access hash:/etc/postfix/local_domains, reject

2.編輯/etc/postfix/check_sender,將要限制的帳號指定到"local_only",帳號須包含網域名稱
           u1@mydomain     local_only

3.編輯/etc/postfix/local_domains,此處指定允許寄件的domain名稱
           mydomain          OK

4.執行postmap產生check_senderlocal_domains的資料檔
postmap check_sender
postmap local_domains

5.重新啟動postfix
service postfix restart

以上!

參考資料:http://www.postfix.org/RESTRICTION_CLASS_README.html