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 ตุลาคม 11, 2016, 02:59:42 PM

Title: การทำ relay mail ใน directadmin exim da
Post by: golfreeze on ตุลาคม 11, 2016, 02:59:42 PM
การทำ relay mail ใน directadmin exim da

ถ้าในกรณีเครื่องที่ส่งเมลของเรา โดน block ชั่วคราว เนื่องการส่งเมลปริมาณมาก หรือ มีติดไวรัส หรือส่งสแปมอีเมลจนทำให้ เป็น IP Blacklist
วิธีการแก้ไขก็คือ ทำการเข้าไปแก้ไขปัญหาที่เป็นต้นตอของเครื่องที่ติดไวรัสซะ เช่น PC เครื่องลูกค้าส่งออกจาก account : abc@example.com
ก็ไปทำเปลี่ยนรหัสผ่านของอีเมลนั้นก่อน แล้วทำสแกน ไวรัส หรือ มัลแวร์ในเครื่อง PC นั้น ใช้โปรแกรมพวก malwarebyte ก็ได้ครับ

หลังจากนั้นทำการแก้ไขปัญหาเฉพาะหน้าโดยการเปลี่ยน SMTP Server หรือทำการ relay mail ออกไปอีกเครื่องหนึ่งแทน ชั่วระยะเวลาสั้นๆ
เพื่อทำการเคลียร์เมลคิว ที่ค้างอยู่ให้สามารถส่งออกไปได้ก่อน
ถ้ากรณีใช้งาน exim เป็น MTA ก็แก้ไขโดย

แก้ไขไฟล์ exim.conf เพื่อให้ใช้ gateway ส่งเมล์ถึง domain ตระกูล hotmail.com , hotmail.co.th , windowslive.com , live.com
โดยเพิ่ม send_to_gateway เข้าไปก่อนหน้า lookuphost: ที่มีอยู่เดิม

# เพิ่มข้อความพวกนี้ก่อน lookuphost:
# Send to gateway
send_to_gateway:
   driver = manualroute
   domains = windowslive.com : live.com : hotmail.com : hotmail.co.il : hotmail.co.jp : hotmail.com.ar : hotmail.com.br : hotmail.com.tr : hotmail.co.th : hotmail.co.uk : hotmail.de : hotmail.es : hotmail.fr : hotmail.it : hotmail.jp : hotmail.se : live.at : live.be : live.ca : live.cl : live.cn : live.co.kr : live.com.ar : live.com.au : live.com.mx : live.com.my : live.com.sg : live.co.za : live.de : live.dk : live.fr : live.hk : live.ie : live.in : live.it : live.jp : live.nl : live.no : live.ru : live.se : msnhotmail.com : outlook.com
   condition = "${perl{check_limits}}"
   transport = remote_smtp
   route_list = * new.ips.add.res

# lookuphost ข้างล่างนี้มีอยู่เดิมแล้ว
lookuphost:
  driver = dnslookup
  domains = ! +local_domains
  ignore_target_hosts = 127.0.0.0/8
  condition = "${perl{check_limits}}"
  transport = remote_smtp
  no_more

ทำการ restart exim 1 รอบ แล้วทำการ monitor maillog ไปพร้อมๆกันครับ ทั้งเครื่องต้นทาง และเครื่องที่ relay mail ออกไป
เท่านี้ก็เรียบร้อยแล้วครับผม : )
Title: Re: การทำ relay mail ใน directadmin exim da
Post by: golfreeze on พฤษภาคม 13, 2021, 06:44:49 PM
มีอีกวิธีในการทำ relay เฉพาะบางโดเมนเพื่อให้ส่งไปยัง relay mail server
เช่นมีโจทย์ว่า sender ต้องการส่งเมลของ gmail.com แล้วให้ relay ไปออกที่เครื่อง 103.8.9.9
เพื่อให้เครื่อง 103.8.9.9 ส่งเมลออกต่อไปให้ยัง gmail.com
 
vi /etc/exim.conf
ไปที่บันทัด
begin routers
แล้วทำการเพิ่ม configure 5 บันทัด หลังจาก begin routers

static_route:
  driver = manualroute
  transport = remote_smtp
  domains = lsearch;/etc/virtual/staticroutes
  route_data = $domain_data

ทำการ save ออกมา
ไปที่ไฟล์
/etc/virtual/staticroutes
เพิ่ม
gmail.com : 103.8.9.9
ทำการ save ออกมา
ทำการ restart service

systemctl restart exim
1 รอบ
แล้วทำการเทสครับ จะเจอว่ามีการ relay ไปยัง server 103.8.9.9
แต่ที่บน 103.8.9.9 ต้อง allow ip ของเครื่องต้นทางไว้ด้วยครับ   ;)

==reference site
https://forum.directadmin.com/threads/send-specific-sender-domains-through-external-smtp.55206/
https://forum.directadmin.com/threads/relay-certain-domain-email-through-external-emal.54019/

==download configure
wget -O /etc/exim.routers.pre.conf http://files.directadmin.com/services/SpamBlocker/smart_route/exim.routers.pre.conf
wget -O /etc/exim.transports.pre.conf http://files.directadmin.com/services/SpamBlocker/smart_route/exim.transports.pre.conf
wget -O /etc/exim.authenticators.post.conf http://files.directadmin.com/services/SpamBlocker/smart_route/exim.authenticators.post.conf
Title: Re: การทำ relay mail ใน directadmin exim da
Post by: golfreeze on กันยายน 28, 2023, 02:58:50 PM
ทำการแจ้งให้ DA Exim รู้ว่าโดเมนไหนบ้างจะให้ relay ไปหา smtp.emsgateway.net::587
ซึ่งตัวอย่างข้างล่างจะให้ packetlove.com relay ไปหา smtp.emsgateway.net::587

#vi /etc/exim.routers.pre.conf

==== add into “exim.routers.pre.conf” =====
smart_route_forward:
    driver = manualroute
    domains = ! +local_domains
    senders = *@packetlove.com
    ignore_target_hosts = 127.0.0.0/8
    condition = ${if !eq{$original_domain}{$domain}}
    condition = ${if !eq{$original_domain}{}}
    condition = "${perl{check_limits}}"
   
    transport = remote_smtp_forward_transport

    route_list = * smtp.emsgateway.net::587
    no_more

smart_route:
    driver = manualroute
    domains = ! +local_domains
    senders = *@packetlove.com
    ignore_target_hosts = 127.0.0.0/8
    condition = "${perl{check_limits}}"

    transport = remote_smtp

    route_list = * smtp.emsgateway.net::587
    no_more
==== add into exim.conf =====

แต่ถ้าต้องการที่จะไม่ให้ โดเมน domain2.to.exclude.com , domain1.to.exclude.com ไม่ให้โดน relay ออกไปด้วยสามารถเขียนได้แบบนี้
senders = !*@domain1.to.exclude.com : !*@domain2.to.exclude.com