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)
PowerShell: Install-WindowsFeature smtp-server → Restart ถ้าจำเป็น
ตั้งค่า SMTP Server (IIS 6 Manager)
Tools → Internet Information Services (IIS) 6.0 Manager หรือ inetmgr6.exe
Right-click SMTP Virtual Server → Properties
- General: เลือก IP (ถ้าหลาย IP) → Enable Logging
- Access → Authentication → Anonymous Access = Enabled
- Access → Connection → Only the list below → ใส่ IP/Subnet ที่อนุญาต (รวม 127.0.0.1)
- Access → Relay → Only the list below → ใส่ IP/Subnet ที่ Relay ได้ (ป้องกัน Open Relay Spam)
Messages: Admin Email (NDR Copy), Limit Message Size, Limit Recipients
Delivery → Outbound Security: Basic Auth + Credentials (เช่น Gmail SMTP ต้อง Allow Less Secure Apps)
Delivery → Advanced: FQDN ของ SMTP Server → Check DNS → Smart Host (เช่น smtp.gmail.com, smtp.office365.com) TLS Port 587 ตั้งใน Outbound Connections
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
สร้าง smtp-test-email.txt บน Desktop:
From: server@localdomain.com
To: admin@localdomain.com
Subject: Email test
This is the test email
Copy ไป C:\inetpub\mailroot\Pickup → SMTP จะส่งอัตโนมัติ
ทดสอบอื่น: Telnet, VBS, PowerShell Send-MailMessage -SMTPServer localhost ...
เช็ค Port 25: Test-NetConnection smtprelay.woshub.com –port 25 Firewall/AV ต้องไม่บล็อก