MTA-STS和TLS-RPT检测器:邮件传输安全完整指南 (2026)
简介
MTA-STS (Mail Transfer Agent Strict Transport Security) คือ RFC 8461 ที่กำหนดให้ Mail Server ที่ส่งอีเมลไปหาโดเมนของคุณ ต้องใช้ TLS ที่ผ่านการตรวจสอบ Certificate แล้วเท่านั้น ป้องกันการโจมตีแบบ SMTP Downgrade ที่แฮกเกอร์บังคับให้ Mail Server ส่งผ่าน Plaintext หรือ TLS ที่ไม่ผ่านการตรวจสอบ
MTA-STS (RFC 8461) is a security standard that tells sending mail servers they must deliver email to your domain using verified TLS — not plaintext, not self-signed certificates. Before MTA-STS, an attacker performing a man-in-the-middle attack on the SMTP path could force servers to downgrade from TLS to plaintext, intercepting email content entirely.
- ป้องกัน SMTP Downgrade Attack
- บังคับให้ Sending Server ใช้ Valid TLS Certificate
- แตกต่างจาก DANE: ไม่ต้องการ DNSSEC บนโดเมนผู้รับ
- ใช้ HTTPS Fetch Policy File = ไม่ต้องพึ่ง DNS ที่อาจถูก Spoof
- Google, Microsoft, FastMail ใช้ MTA-STS แล้ว
重要性
ก่อน MTA-STS อีเมลที่ส่งระหว่างเซิร์ฟเวอร์อาจ Downgrade เป็น Plaintext ได้ถ้าแฮกเกอร์ขัดขวาง STARTTLS Negotiation ปัญหานี้เรียกว่า STARTTLS Stripping ซึ่ง MTA-STS ป้องกันได้โดยกำหนดไว้ล่วงหน้า (Out-of-Band) ว่าต้องใช้ TLS เสมอ
STARTTLS, the most common email encryption mechanism, is vulnerable to downgrade attacks. An attacker with network access between two mail servers can strip the STARTTLS capability advertisement, forcing servers to communicate in plaintext. MTA-STS prevents this by publishing the TLS requirement as an HTTPS-fetched policy, separate from the mail delivery path that an attacker might manipulate.
- STARTTLS Stripping: แฮกเกอร์ตัด STARTTLS ออกจาก SMTP Negotiation
- Plaintext SMTP: อีเมลทั้งหมด ส่งโดยไม่เข้ารหัส
- MTA-STS แก้: Sending Server ดึง Policy ก่อนส่ง ถ้าไม่มี Valid TLS = ส่งไม่ได้เลย
- ประยุกต์ใช้ในองค์กร: GDPR, PDPA กำหนดให้ข้อมูลส่วนตัวต้องส่งแบบเข้ารหัส
策略文件
Policy File คือไฟล์ Text ธรรมดาที่ต้องอยู่ที่ https://mta-sts.yourdomain.com/.well-known/mta-sts.txt Subdomain mta-sts ต้องมี Valid SSL Certificate เพราะ Sending Server จะ Fetch Policy ผ่าน HTTPS
The MTA-STS policy is a plain-text file served over HTTPS at a specific path on a subdomain. The subdomain must have a valid TLS certificate because sending servers verify it during the policy fetch. The policy specifies three key fields: the enforcement mode, the list of authorised MX hosts, and how long servers may cache the policy.
version: STSv1
mode: enforce
mx: mail.example.com
mx: mail2.example.com
max_age: 604800
- mode: testing — บันทึก Log แต่ไม่ Enforce (ใช้ก่อน enforce เพื่อทดสอบ)
- mode: enforce — Sending Server ต้องใช้ Valid TLS หรือไม่ส่ง
- mode: none — ปิด MTA-STS ชั่วคราว
- max_age: วินาทีที่ Cache Policy ได้ (604800 = 7 วัน)
- mx: MX Host ที่อนุญาต (ต้องตรงกับ MX Record จริง)
TXT记录
TXT Record ที่ _mta-sts.yourdomain.com บอก Sending Server ว่าโดเมนนี้มี MTA-STS Policy และอยู่ที่ Version ใด ค่า id= ต้องเปลี่ยนทุกครั้งที่แก้ Policy File เพื่อให้ Server ที่ Cache ไว้รู้ว่า Policy เปลี่ยนแล้ว
The _mta-sts TXT record signals to sending servers that an MTA-STS policy exists for this domain. The id= field acts as a version identifier — it must change every time the policy file changes so that mail servers that have cached the old policy know to fetch the new one.
_mta-sts.example.com. 300 IN TXT "v=STSv1; id=20260627T000000Z;"
- TTL แนะนำ 300 วินาที (เปลี่ยนได้เร็ว)
- id= เปลี่ยนทุกครั้งที่แก้ Policy (ใช้ Timestamp หรือ Sequential Number)
- Sending Server Fetch Policy ใหม่เมื่อเห็น id= เปลี่ยน
- ตรวจสอบด้วย: Analyze.in.th MTA-STS Checker
TLS-RPT报告
TLS-RPT (TLS Reporting, RFC 8460) เป็นส่วนเสริมของ MTA-STS ที่ให้ Mail Server รายงานปัญหา TLS Connection กลับมาหาคุณ เพื่อให้รู้ว่ามี Server ใดที่ไม่สามารถส่งอีเมลได้เพราะ Policy ของคุณ
TLS-RPT (RFC 8460) complements MTA-STS by giving you visibility into TLS connection failures. Sending servers submit aggregate reports to the address you specify in the _smtp._tls TXT record, telling you how many sessions succeeded and failed, and why. This is invaluable when you first switch to enforce mode.
_smtp._tls.example.com. 300 IN TXT "v=TLSRPTv1; rua=mailto:[email protected];"
- Sending Server ส่ง Daily Report ว่ามี TLS Failure เท่าไรต่อโดเมน
- Report Format: JSON (GZIP) ส่งมาเป็น Email Attachment
- ข้อมูลใน Report: Success/Failure Count, Error Type, Sending IP
- ใช้ Mode Testing + TLS-RPT เพื่อดู Failure ก่อน Enforce
使用方法
เครื่องมือ MTA-STS Checker ที่ Analyze.in.th ตรวจสอบทุกส่วนของ MTA-STS ในครั้งเดียว: TXT Record, Policy File, Mode และ TLS-RPT
The Analyze.in.th MTA-STS Checker verifies every component of your MTA-STS setup in one step: the _mta-sts TXT record, the HTTPS policy file reachability and content, the enforcement mode, MX host list, and the _smtp._tls TLS-RPT record.
- เปิด https://dnsxray.com/mta-sts.php
- พิมพ์ชื่อโดเมนในช่องค้นหา เช่น
gmail.com - กด Check MTA-STS
- ผลลัพธ์แสดง: TXT Record, Policy File Content, Mode, max_age, MX List, TLS-RPT
Results include: _mta-sts TXT record status; policy file reachability and full content (version, mode, MX hosts, max_age); policy ID match between TXT and file; and _smtp._tls TLS-RPT record with reporting URI.
配置步骤
การตั้งค่า MTA-STS ต้องสร้าง Subdomain, ทำ Policy File, และเพิ่ม TXT Record 2 อัน ทำตามลำดับนี้เพื่อหลีกเลี่ยงปัญหา
MTA-STS setup requires three steps: create the mta-sts subdomain with HTTPS, publish the policy file at the correct path, and add two TXT records. Do this in order — publishing the TXT record before the policy file is reachable can cause sending servers to report failures.
- สร้าง Subdomain:
mta-sts.yourdomain.comพร้อม Valid SSL (Let's Encrypt) - สร้าง Policy File:
/.well-known/mta-sts.txtเนื้อหา mode: testing ก่อน - เพิ่ม TXT Record:
_mta-sts.yourdomain.com=v=STSv1; id=20260627T000000Z; - เพิ่ม TLS-RPT:
_smtp._tls.yourdomain.com=v=TLSRPTv1; rua=mailto:[email protected]; - Monitor Report: รอรับ Report 7 วัน ตรวจว่าไม่มี Failure
- เปลี่ยนเป็น enforce: เปลี่ยน
mode: enforceและเปลี่ยนid=ใน TXT
常见问题
ปัญหาที่พบบ่อยที่สุดใน MTA-STS Setup คือ SSL Certificate ของ mta-sts Subdomain หมดอายุ หรือ Policy File ไม่ถูก Serve ด้วย Content-Type ถูกต้อง
The most common MTA-STS problems are: the mta-sts subdomain SSL certificate expiring (this immediately breaks policy delivery for sending servers); the policy file served with the wrong Content-Type header; the MX host list in the policy not matching actual MX records; and forgetting to update the id= field after changing the policy.
- Policy Fetch Failed: SSL Cert ของ mta-sts Subdomain หมดอายุ
- MX Mismatch: MX ใน Policy ไม่ตรงกับ MX Record จริง
- ID Stale: ลืมเปลี่ยน id= หลังแก้ Policy → Server ไม่ Fetch ใหม่
- Wrong Content-Type: Policy File ต้องมี
Content-Type: text/plain - ตรวจสอบปัญหา: Analyze.in.th บอก Error แต่ละข้อ
主机推荐
MTA-STS ตั้งค่าได้บน Hosting ทุกเจ้าที่ให้คุณสร้าง Subdomain และติดตั้ง SSL ได้ ไม่ต้องพึ่ง Hosting ที่ Support MTA-STS โดยเฉพาะ เพราะ Policy File คือ Static Text File ธรรมดา
MTA-STS can be configured on any hosting that lets you create a subdomain and install a TLS certificate — no special server software is required because the policy file is just a plain text file served over HTTPS. What matters is that your email routing uses MX hosts you control, and that those hosts support valid TLS. AsiaGB.com provides hosting with SSD storage, DirectAdmin, and 24-hour Thai-language support.
- ต้องการแค่: Subdomain + SSL + Static File Hosting
- Let's Encrypt ฟรีสำหรับ mta-sts.yourdomain.com
- AsiaGB.com: Hosting SSD, DirectAdmin, Support ภาษาไทย 24 ชม., uptime 99%
- ตรวจสอบ Setup: dnsxray.com/mta-sts.php