Golfreeze.packetlove.com: Life style of Golfreeze Canon400D Family kammtan.com Jazz Freebsd Unix Linux System Admin guitar Music
All about unix linux freebsd and FAQ for Packetlove.com Web hosting , Mail hosting , VoIP + IP PBX server => Mail issue , problem , configuration => Topic started by: golfreeze on มกราคม 23, 2011, 10:18:10 pm
-
โจทย์ ใช้ MTA : Postfix
OS : Freebsd
ครับ
จะ set ให้ บาง user= golf@example.com สามารถส่งเมลออกไป domain ข้างนอกไม่ได้ (Ex.
golfreeze@hotmail.com , sss@yahoo.com )
แต่ว่ามีให้ user= golfreeze@example.com ส่งได้ จะต้อง set อย่างไงบ้าง
ก่อนอื่นต้องทำความเข้าใจก่อนว่า ไฟล์ไหนของ postfix ทำงานอย่างไร ทำงานอะไร
ในกรณีนี้ เราต้องแก้ไขที่ไฟล์ main.cf ครับ
เพิ่มในส่วนของ
###Allow some user sending email off-site #####
smtpd_sender_restrictions=check_sender_access hash:/usr/local/etc/postfix/sender_restrictions
smtpd_restriction_classes = local_only
local_only =
check_recipient_access hash:/usr/local/etc/postfix/local_domains, reject
##### End of Config ########
แล้วทำการแอด mail account ที่จะใช้กับ policy check_sender_access นีัครับ
#vi /usr/local/etc/postfix/sender_restrictions
golf@example.com local_only
#postmap /usr/local/etc/postfix/sender_restrictions
#vi /usr/local/etc/postfix/local_domains
เพิ่ม domain ที่จะให้บังคับใช้งาน policy นี้
example.com OK
#postmap /usr/local/etc/postfix/local_domains
แล้วทำการ restart postfix 1 รอบ แล้วลองส่งดูครับ
smtp00# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 smtp.packetlove.com ESMTP Postfix
helo e
250 smtp.packetlove.com
ehlo e
250-smtp.packetlove.com
250-PIPELINING
250-SIZE 102400000
250-ETRN
250-AUTH LOGIN
250-AUTH=LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: golf@example.com
250 2.1.0 Ok
rcpt to: golfreeze@hotmail.com
554 5.7.1 < golf@example.com>;: Sender address rejected: Access denied
quit
221 2.0.0 Bye
Connection closed by foreign host.
### ใช้งานได้แล้ว ###
m_golfreeze.gif golfreeze [2009-12-08 15:54:50] mail not show 116.68.146.74
1
Comment : 1
### อ่านเพิ่มเติมได้ที่
http://www.postfix.org/RESTRICTION_CLASS_README.html#external
-
### อ่านเพิ่มเติมได้ที่
http://www.postfix.org/RESTRICTION_CLASS_README.html#external
-
มีอีกกรณีครับ สมมติว่า ไม่การให้ user บาง คน รับเมลจาก ภายนอกได้
ก็สามารถ config ที่ไฟล์ main.cf ของ postfix ได้ตามนี้นะครับ
###Not allow to receive email from External domain
smtpd_recipient_restrictions =
check_recipient_access hash:/usr/local/etc/postfix/protected_destinations
smtpd_restriction_classes = insiders_only
insiders_only =
check_sender_access hash:/usr/local/etc/postfix/insiders, reject
##############################################
เพิ่มconfig file "insiders" ด้วย domain ที่จะทำการจำกัดสิทธิ์ดังนี้
example.com OK
เพิ่มconfig file "protected_destinations" ด้วย email account
ที่จะทำการจำกัดสิทธิ์ดังนี้
pass@example.com insiders_only
#postmap /usr/local/etc/postfix/insiders
#postmap /usr/local/etc/postfix/protected_destinations
#/usr/local/etc/rc.d/postfix restart
โดยที่ ถ้ามี account ss@hotmail.com คือปลายทางส่งเข้ามาถึง user "pass@example.com ที่อยู่ใน
list ปลายทางจะได้รับ error message ว่า
################################################
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
pass@example.com
SMTP error from remote mail server after RCPT TO:<pass@example.com>;:
host mx1.example.com [11.111.11.1]: 554 5.7.1 <pass@example.com>;:
Recipient address rejected: Access denied
#########################################
-
ถ้าต้องการให้ account ใน example.com ส่งเข้าได้เฉพาะ domain
example.com
hotmail.com
ก็เพิ่มในไฟล์ local_domains เป็น
example.com OK
hotmail.com OK
postmap /etc/postfix/local_domains
/etc/init.d/postfix restart
-
เราสามารถทำ relayhost ได้ปล่าวครับ
relayhost ไปที่ smtp.3bbmail.com
ขอบคุณครับ
-
เราสามารถทำ relayhost ได้ปล่าวครับ
relayhost ไปที่ smtp.3bbmail.com
ขอบคุณครับ
ปกติพวก mta อย่าง postfix , exim , sendmail สามารถทำ relayhost ได้อยู่แล้วนะครับผม
แต่ในส่วนนี้จะเป็นการทำ restriction อ่าครับ ระบุเฉพาะเจาะจง ว่า user ใดสามารถส่งหาใครได้บ้าง ห้ามส่งหาใครบ้างครับผม