Postfix 設定讓某帳號只能收郵件, 但無法寄出郵件

首先建立了一個/etc/postfix/reject_user, 填入要封鎖的帳號資料, 建立該db檔.

然後編輯 vi /etc/postfix/main.cf, 並將加入check_sender_access hash:/etc/postfix/reject_user在下面兩項敘述中

smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/reject_user permit_mynetworks     permit_sasl_authenticated     reject_rbl_client cbl.abuseat.org     reject_rbl_client list.dsbl.org     reject_rbl_client sbl.spamhaus.org     reject_rbl_client pbl.spamhaus.org     reject_rbl_client bl.spamcop.net     reject_rbl_client cblless.anti-spam.org.cn     reject_rbl_client psbl.surriel.com     reject_rbl_client bl.spamcop.net     reject_unknown_sender_domain     reject_unknown_recipient_domain     reject_unauth_destination      reject_invalid_hostname     reject_non_fqdn_hostname     reject_non_fqdn_sender,     reject_non_fqdn_recipient,

smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/reject_user, permit_mynetworks, reject_unknown_client, reject_unknown_sender_domain, reject_invalid_hostname, reject_non_fqdn_hostname, reject_non_fqdn_sender

要加入封鎖寄信功能帳號的步驟入下(以postfix系統為例; sendmail應該無法適用):

1. #用vi指令編輯/etc/postfix/reject_user

[root@mail1 ~]# vi /etc/postfix/reject_user 

#填入以下資料, 例如預計要封鎖寄信的帳號user@test.com.twuser2@test.com.tw

user@test.com.tw REJECT

user2@test.com.tw REJECT

#編輯完成後, 按esc退出編輯模式, Ctrl+wq存檔離開/etc/postfix/reject_user.

2. #建立map db檔

[root@mail1 ~]# postmap hash:/etc/postfix/reject_user

#如果填入資料正確, 上面指令不會出現任何錯誤訊息

3. #重新啟動postfix

[root@mail1 ~]# /etc/init.d/postfix restart

正在關閉 postfix:                                          [  確定  ]

正在啟動 postfix:                                          [  確定  ]


這樣user@test.com.twuser2@test.com.tw就無法寄信, 會被系統直接退信; 但別人寄給他的mail全部都可以收.

將REJECT改成DISCARD, 則是會直接丟棄mail.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.