How To Install and Configure Postfix as a Send-Only SMTP Server on Ubuntu

Postfix เป็น MTA (Mail Transfer Agent) แอปพลิเคชันที่ใช้ในการส่งและรับอีเมล ในบทแนะนำนี้เราจะติดตั้งและกำหนดค่า Postfix เพื่อให้สามารถใช้เพื่อส่งอีเมลโดยใช้แอพพลิเคชันภายในเท่านั้นนั่นคือเครื่องที่ติดตั้งบนเซิร์ฟเวอร์เดียวกันกับ Postfix

Rachata Tongpagdee
2 min readMay 7, 2018

โดยบทความนี้จะเป็นการทดสอบส่ง Email จากเครื่อง Server Ubuntu ที่ลงอยู่ใน Vmwere ไปยัง Email ภายนอก

วิธีการติดตั้ง

Step 1 — Install Postfix

$ sudo apt-get upgrade$ sudo apt-get update$ sudo apt-get install mailutils

การติดตั้ง mailtuils จะทำให้ติดตั้ง Postfix รวมทั้งโปรแกรมอื่น ๆ ที่จำเป็นสำหรับ Postfix ของเรา *****อย่า Upgrade+Update ก่อนนะ

เลือกเป็น Internet Site

ชื่อ system mail name แนะนำเป็นชื่อ Domain Name ของเรา เช่น demo.com

Step 2 — Configure Postfix

$ sudo nano /etc/postfix/main.cf

แก้ไขค่าจาก inet_interfaces = all ไปเป็น inet_interfaces = localhost ภายในไฟล์ /etc/postfix/main.cf

ทำการ Restart postfix

$ sudo service postfix restart

Step 3 — Test That the SMTP Server Can Send Emails

ทดสอบการส่งเข้า Email จริง

echo "This is the body of the email" | mail -s "This is the subject line" eakkabin_it@hotmail.comecho "This is the body of the email" | mail -s "This is the subject line" paretk7@gmail.com

Step 4 — Forward System Mail

$ sudo nano /etc/aliases
$ sudo newaliases
$ echo "This is the body of the email" | mail -s "This is the subject line" root

--

--