Showing posts with label สคริป. Show all posts
Showing posts with label สคริป. Show all posts

Thursday, March 21, 2019

ปรับแต่งสคริป send mail alert โดยให้ส่งผ่าน smtp ที่ต้องการ

ปรับแต่งสคริป เพื่อให้ส่งเมลผ่านไปยัง smtp ที่เราทำไว้สำหรับส่งเมล ไม่ให้ส่งออกจากเครื่อง Server นั้น ๆ

สคริป

echo "Check all health hard disk backup complete" | mail -S smtp=IP:PORT -s "Check smart disk on Data Center was completed" -r noreply@domain.com -q /root/checkhealthdisk.txt -v admin@domain.com

คำอธิบาย


  • echo "Check all health hard disk backup complete" ใส่ข้อความเข้าไปในส่วนล่างสุดของเมล
  • mail -S smtp=IP:PORT ใส่ค่า smtp server ที่ต้องการเช่น 192.168.0.2 และพอร์ต 25 ตัวอย่าง 192.168.0.2:25
  • -s "Check smart disk on Data Center was completed" คือ Subject mail
  • -r noreply@domain.com คือ Sender mail
  • -q /root/checkhealthdisk.txt คือ กรณีมีไฟล์ที่ต้องการแนบไปในเมล
  • -v admin@domain.com คือ Receive mail (ผู้ร้บเมล)