Postfix logoPostfix คือ MTA ที่มีความยืดหยุ่นในการใช้งานที่สูงมาก เราสามารถแก้ไขและปรับแต่งค่าได้ตามที่ต้องการ อย่างเช่นในบทความนี้ จะมาพูดถึง วิธีการกำหนดขอบเขตการส่ง email ของบาง user ให้สามารถส่งได้เพียงโดเมนที่เราต้องการ หรือ การกำหนดให้บาง user สามารถส่ง email ได้เฉพาะภายในบริษัทเท่านั้น

วิธีการ configure เราจะต้องสร้าง lookup table ขึ้นมา 2 lookup tables โดยที่ lookup table แรกจะใช้ในการจำกัดขอบเขตการส่ง email ของ user (ในที่นี้คือไฟล์ restricted_senders) และอีก lookup table หนึ่งจะใช้ในการกำหนดว่า user ที่อยู่ใน lookup table แรกสามารถส่งไปได้ที่โดเมนไหนบ้าง (ในที่นี้คือไฟล์ local_domains)

ขั้นตอนการ configure ให้ให้บาง user สามารถส่ง email ได้เฉพาะภายในบริษัทหรือโดเมนที่กำหนด

  1. แก้ไขไฟล์ /etc/postfix/main.cf โดยเพิ่ม
    [shell]smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/restricted_senders
    smtpd_restriction_classes = local_only
    local_only = check_recipient_access hash:/etc/postfix/local_domains, reject
    [/shell]
  2. สร้างไฟล์ restricted_senders ที่ /etc/postfix/ ด้วยคำสั่ง
    [text][root@Ezylinux ~]# vi /etc/postfix/restricted_senders[/text]
    จากนั้นกำหนด email ที่ต้องการให้ส่งได้เฉพาะภายใน โดยใส่ email และตามด้วย local_only
    ตัวอย่าง 
    [text][email protected] local_only
    [email protected] local_only
    [/text]
    เมื่อสร้างเสร็จแล้วให้ใช้คำสั่ง
    [shell][root@Ezylinux ~]# cd /etc/postfix/
    [root@Ezylinux ~]# postmap restricted_senders[/shell]
  3. สร้างไฟล์ local_domains ที่ /etc/postfix/ ด้วยคำสั่ง
    [shell][root@Ezylinux ~]# vi /etc/postfix/local_domains[/shell]
    จากนั้นกำหนด domain ที่ต้องการให้ email ที่อยู่ใน restricted_senders ส่งหาได้ และตามด้วย OK
    ตัวอย่าง 
    [text]ezylinux.com OK[/text]
    เมื่อสร้างเสร็จแล้วให้ใช้คำสั่ง
    [shell][root@Ezylinux ~]# cd /etc/postfix/
    [root@Ezylinux ~]# postmap local_domains[/shell]

เมื่อทดสอบการส่งไปที่โดเมนต่างๆ กับ user ที่จำกับขอบเขตการส่ง ถ้า user นั้นไม่ได้รับอนุญาติให้ส่งระบบจะส่งเมล์ตอบกลับมาโดยมีข้อความ error ดังข้างล่าง
[text]554 5.7.1 : Sender address rejected: Access denied;[/text]