How to block external email from domains or individual email

Published On Sunday, November 29th, 2015


วิธีการตั้งค่าให้ระบบ ZIMBRA ทำการ reject email จากภายนอกไม่ให้สามารถส่งเข้าไปยัง user ภายในระบบได้ หรือการทำ blacklist email สามารถทำตามขั้นตอนได้ดังนี้

1. ตั้งค่า smtpd_sender_restrictions ดังตัวอย่างด้านล่าง

ZIMBRA 7:
รันคำสั่ง
$ zmlocalconfig -e postfix_smtpd_sender_restrictions="hash:/opt/zimbra/postfix/conf/postfix_reject_sender"

ZIMBRA 8.0:
เพิ่ม “client_sender_access hash:/opt/zimbra/postfix/conf/postfix_reject_sender” เข้าไปยังไฟล์ /opt/zimbra/conf/zmconfigd/smtpd_sender_restrictions.cf

ZIMBRA 8.5 และ 8.6:
แก้ไขไฟล์ /opt/zimbra/conf/zmconfigd/smtpd_sender_restrictions.cf โดยเพิ่มข้อความด้านล่างไปที่บรรทัดที่ 2

%%contains VAR:zimbraMtaSmtpdSenderRestrictions check_sender_access lmdb:/opt/zimbra/postfix/conf/postfix_reject_sender%%

และรันคำสั่ง
$ zmprov ms `zmhostname` +zimbraMtaSmtpdSenderRestrictions "check_sender_access lmdb:/opt/zimbra/postfix/conf/postfix_reject_sender"

2. สร้างไฟล์ /opt/zimbra/postfix/conf/postfix_reject_sender โดยที่ภายในไฟล์มีลิสต์ของ email หรือ domain ที่ต้องการจะ block แล้วตามด้วย REJECT ดังตัวอย่าง
[email protected] REJECT
domain.com REJECT

3. รันคำสั่ง postmap เพื่อสร้าง database และ restart postfix

$ /opt/zimbra/postfix/sbin/postmap /opt/zimbra/postfix/conf/postfix_reject_sender
$ zmmtactl stop && zmmtactl start

** เราสามารถใช้ Amavis ทำ blacklist แทนได้