Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows Server

ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

Windows Server มี SMTP Service Built-in ทำเป็น Mail Relay รับส่ง SMTP จากอุปกรณ์ (Scanner, Access Control) และแอป (Web, SQL Reporting, SharePoint) ส่งต่อไป Exchange หรือ Gmail/Office365 ไม่ต้อง Deploy Exchange Full

ติดตั้ง SMTP Service

Server Manager → Add Roles and Features → Features → SMTP Server (Prompt ติดตั้ง IIS Management Tools)

ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019 ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

PowerShell: Install-WindowsFeature smtp-server → Restart ถ้าจำเป็น

ตั้งค่า SMTP Server (IIS 6 Manager)

Tools → Internet Information Services (IIS) 6.0 Manager หรือ inetmgr6.exe

ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

Right-click SMTP Virtual Server → Properties

ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019
  1. General: เลือก IP (ถ้าหลาย IP) → Enable Logging
  2. ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019
  3. Access → Authentication → Anonymous Access = Enabled
  4. ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019
  5. Access → Connection → Only the list below → ใส่ IP/Subnet ที่อนุญาต (รวม 127.0.0.1)
  6. Access → Relay → Only the list below → ใส่ IP/Subnet ที่ Relay ได้ (ป้องกัน Open Relay Spam)
  7. ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

Messages: Admin Email (NDR Copy), Limit Message Size, Limit Recipients

ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

Delivery → Outbound Security: Basic Auth + Credentials (เช่น Gmail SMTP ต้อง Allow Less Secure Apps)

ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

Delivery → Advanced: FQDN ของ SMTP Server → Check DNS → Smart Host (เช่น smtp.gmail.com, smtp.office365.com) TLS Port 587 ตั้งใน Outbound Connections

ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

Save → Restart SMTP Virtual Server

DNS สำคัญ: PTR Record ต้องชี้ FQDN ของ Server ไม่งั้น External SMTP Reject (Spam)

SMTPSVC Auto-Start

set-service smtpsvc -StartupType Automatic
start-service smtpsvc
get-service smtpsvc
ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

ทดสอบ SMTP Server

สร้าง smtp-test-email.txt บน Desktop:

From: server@localdomain.com
To: admin@localdomain.com
Subject: Email test
This is the test email
ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

Copy ไป C:\inetpub\mailroot\Pickup → SMTP จะส่งอัตโนมัติ

ติดตั้งและตั้งค่า SMTP Server บน Windows Server 2016/2012 R2/2019

ทดสอบอื่น: Telnet, VBS, PowerShell Send-MailMessage -SMTPServer localhost ...

เช็ค Port 25: Test-NetConnection smtprelay.woshub.com –port 25 Firewall/AV ต้องไม่บล็อก