
ทำไม Email Security ถึงสำคัญในปี 2026?
Email ยังคงเป็นช่องทางโจมตีอันดับ 1 สำหรับ Cyber Attack ในปี 2026 มากกว่า 90% ของการโจมตีเริ่มต้นจาก Email ไม่ว่าจะเป็น Phishing, Spoofing, BEC (Business Email Compromise) หรือ Malware การตั้งค่า SPF, DKIM, DMARC อย่างถูกต้องเป็นสิ่งจำเป็นพื้นฐาน
ภัยคุกคาม Email หลัก
| ประเภท | วิธีการ | ผลกระทบ | ป้องกันด้วย |
|---|---|---|---|
| Phishing | ส่ง Email ปลอมหลอกให้กรอกข้อมูล | ขโมย Username/Password, ข้อมูลบัตรเครดิต | DMARC + User Training |
| Email Spoofing | ปลอมแปลง From Address | ส่ง Email เป็นชื่อองค์กรคุณ | SPF + DKIM + DMARC |
| BEC | ปลอมเป็น CEO/CFO สั่งโอนเงิน | สูญเสียเงินหลักล้าน-หลักร้อยล้าน | DMARC + Approval Process |
| Malware | แนบ File อันตราย | Ransomware, Trojan, Spyware | Email Gateway + Anti-malware |
| Spam | ส่ง Email ขยะปริมาณมาก | สิ้นเปลือง Bandwidth, กรอง Email ยาก | Anti-spam + SPF/DKIM |
SPF (Sender Policy Framework)
SPF คืออะไร?
SPF คือ DNS TXT Record ที่ระบุว่า “Mail Server ไหนได้รับอนุญาตให้ส่ง Email จากโดเมนของคุณ” เมื่อ Receiving Server ได้รับ Email จะตรวจสอบว่า IP ของ Sending Server ตรงกับ SPF Record หรือไม่
SPF Mechanisms
| Mechanism | ความหมาย | ตัวอย่าง |
|---|---|---|
| ip4: | อนุญาต IPv4 Address/Range | ip4:203.0.113.50 |
| ip6: | อนุญาต IPv6 Address/Range | ip6:2001:db8::/32 |
| a | อนุญาต A Record ของโดเมน | a:mail.example.com |
| mx | อนุญาต MX Record ของโดเมน | mx |
| include: | รวม SPF Record ของโดเมนอื่น | include:_spf.google.com |
| all | ตรงกับทุก IP (ใช้กับ Qualifier) | -all (reject ทั้งหมดที่เหลือ) |
SPF Qualifiers
| Qualifier | ความหมาย | แนะนำ? |
|---|---|---|
| + (Pass) | อนุญาต (Default) | ใช้สำหรับ Server ที่ Trust |
| – (Fail) | ปฏิเสธ (Hard Fail) | แนะนำสำหรับ -all |
| ~ (SoftFail) | น่าจะไม่ใช่ แต่ไม่ reject | ใช้ตอนทดสอบ |
| ? (Neutral) | ไม่มีความเห็น | ไม่แนะนำ |
ตัวอย่าง SPF Record
# SPF สำหรับ Google Workspace
v=spf1 include:_spf.google.com -all
# SPF สำหรับ Microsoft 365
v=spf1 include:spf.protection.outlook.com -all
# SPF สำหรับ Mail Server + Google + Third-party
v=spf1 ip4:203.0.113.50 include:_spf.google.com include:sendgrid.net -all
# SPF สำหรับ DirectAdmin Server
v=spf1 mx ip4:122.155.168.7 -all
# ตั้งค่าใน DNS (TXT Record):
# Host: @ (หรือ example.com)
# Type: TXT
# Value: v=spf1 include:_spf.google.com -all
# TTL: 3600
DKIM (DomainKeys Identified Mail)
DKIM คืออะไร?
DKIM คือ Email Authentication ที่ใช้ Digital Signature ลงนามใน Email Header เมื่อ Email ถูกส่งออก ทำให้ Receiving Server สามารถยืนยันว่า Email นั้น:
- ส่งมาจากโดเมนจริง (ไม่ถูก Spoof)
- เนื้อหาไม่ถูกแก้ไขระหว่างทาง (Integrity)
วิธีทำงานของ DKIM
# ขั้นตอน DKIM:
# 1. สร้างคู่ Key: Private Key (เก็บบน Mail Server) + Public Key (ใส่ DNS)
# 2. เมื่อส่ง Email → Mail Server ใช้ Private Key ลงนามใน Header
# 3. Receiving Server ดึง Public Key จาก DNS
# 4. ตรวจสอบ Signature → ตรง = PASS, ไม่ตรง = FAIL
# DKIM Signature ใน Email Header:
# DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
# d=example.com; s=selector1;
# h=from:to:subject:date:message-id;
# bh=base64hash...;
# b=signature...
ตั้งค่า DKIM
# 1. สร้าง DKIM Key Pair
# Google Workspace: Admin Console → Apps → Google Workspace → Gmail → Authenticate email
# Microsoft 365: Exchange Admin → Protection → DKIM
# 2. สำหรับ Server ส่วนตัว (OpenDKIM):
# ติดตั้ง
sudo apt install opendkim opendkim-tools
# สร้าง Key
sudo opendkim-genkey -s mail -d example.com
# → สร้าง mail.private (Private Key) และ mail.txt (DNS Record)
# 3. ใส่ Public Key ใน DNS:
# Host: mail._domainkey (selector._domainkey)
# Type: TXT
# Value: v=DKIM1; k=rsa; p=MIIBIjANBgk...public_key_here...
# 4. Key Rotation (แนะนำทุก 6-12 เดือน)
# สร้าง Key ใหม่ด้วย Selector ใหม่ (เช่น mail2)
# เพิ่ม DNS Record ใหม่
# เปลี่ยน Mail Server ใช้ Key ใหม่
# รอ 48 ชั่วโมง แล้วลบ Key เก่าจาก DNS
DMARC (Domain-based Message Authentication, Reporting, and Conformance)
DMARC คืออะไร?
DMARC คือ Email Authentication Protocol ที่ สร้างบน SPF + DKIM เพื่อบอก Receiving Server ว่า “ถ้า Email ไม่ผ่าน SPF/DKIM จะทำยังไง?” และส่ง Report กลับมาให้เจ้าของโดเมนตรวจสอบ
DMARC Policy Levels
| Policy | พฤติกรรม | เมื่อไรใช้ |
|---|---|---|
| p=none | ไม่ทำอะไร แค่ Monitor + ส่ง Report | เริ่มต้น — เก็บข้อมูลก่อน |
| p=quarantine | ส่งไป Spam/Junk ถ้าไม่ผ่าน | ขั้นกลาง — เริ่ม Enforce |
| p=reject | ปฏิเสธ Email ที่ไม่ผ่าน | ขั้นสุดท้าย — Protection เต็มรูปแบบ |
DMARC Alignment
DMARC ตรวจสอบ Alignment คือ Domain ใน From Header ต้องตรงกับ Domain ที่ SPF/DKIM ยืนยัน
# Alignment Modes:
# strict (s): Domain ต้องตรงกัน exact
# From: [email protected] → SPF/DKIM domain: example.com ✓
# From: [email protected] → SPF/DKIM domain: sub.example.com ✗
# relaxed (r): Subdomain ก็ได้ (Default)
# From: [email protected] → SPF/DKIM domain: example.com ✓
# From: [email protected] → SPF/DKIM domain: sub.example.com ✓
ตั้งค่า DMARC Record
# DMARC DNS Record:
# Host: _dmarc
# Type: TXT
# Step 1: เริ่มด้วย Monitor (p=none)
v=DMARC1; p=none; rua=mailto:[email protected]; ruf=mailto:[email protected]; pct=100
# Step 2: หลัง Monitor 2-4 สัปดาห์ → Quarantine
v=DMARC1; p=quarantine; rua=mailto:[email protected]; pct=25
# Step 3: เพิ่ม pct เป็น 50%, 75%, 100%
v=DMARC1; p=quarantine; rua=mailto:[email protected]; pct=100
# Step 4: เปลี่ยนเป็น Reject (Full Protection)
v=DMARC1; p=reject; rua=mailto:[email protected]; pct=100
# DMARC Tags:
# v=DMARC1 — Version (จำเป็น)
# p=none/quarantine/reject — Policy (จำเป็น)
# rua=mailto:... — Aggregate Report ส่งไปไหน
# ruf=mailto:... — Forensic Report ส่งไปไหน
# pct=100 — เปอร์เซ็นต์ที่ Apply Policy (0-100)
# adkim=r — DKIM Alignment (r=relaxed, s=strict)
# aspf=r — SPF Alignment (r=relaxed, s=strict)
# sp=none — Subdomain Policy
ตั้งค่า SPF + DKIM + DMARC Step-by-Step
สำหรับ Google Workspace
# Step 1: SPF
# DNS TXT Record:
# Host: @
# Value: v=spf1 include:_spf.google.com -all
# Step 2: DKIM
# Google Admin Console → Apps → Gmail → Authenticate email
# Generate DKIM key → Copy DNS record
# DNS TXT Record:
# Host: google._domainkey
# Value: v=DKIM1; k=rsa; p=MIIBIjANBgk...
# Step 3: DMARC (เริ่ม Monitor)
# DNS TXT Record:
# Host: _dmarc
# Value: v=DMARC1; p=none; rua=mailto:[email protected]
สำหรับ Microsoft 365
# Step 1: SPF
# DNS TXT Record:
# Host: @
# Value: v=spf1 include:spf.protection.outlook.com -all
# Step 2: DKIM
# Exchange Admin → Protection → DKIM → Enable
# DNS CNAME Records:
# selector1._domainkey → selector1-example-com._domainkey.example.onmicrosoft.com
# selector2._domainkey → selector2-example-com._domainkey.example.onmicrosoft.com
# Step 3: DMARC
# DNS TXT Record:
# Host: _dmarc
# Value: v=DMARC1; p=none; rua=mailto:[email protected]
ทดสอบ Email Authentication
เครื่องมือทดสอบ
| เครื่องมือ | URL | ตรวจอะไร |
|---|---|---|
| MXToolbox | mxtoolbox.com/SuperTool.aspx | SPF, DKIM, DMARC, Blacklist, MX |
| mail-tester.com | mail-tester.com | Email Score (SPF/DKIM/DMARC + Content) |
| Google Admin Toolbox | toolbox.googleapps.com/apps/checkmx | MX, SPF, DKIM, DMARC |
| DMARC Analyzer | dmarcanalyzer.com | DMARC Report Analysis |
| learndmarc.com | learndmarc.com | ทดสอบ + เรียนรู้ SPF/DKIM/DMARC |
# ทดสอบด้วย Command Line:
# ตรวจ SPF
dig TXT example.com +short
nslookup -type=TXT example.com
# ตรวจ DKIM
dig TXT google._domainkey.example.com +short
# ตรวจ DMARC
dig TXT _dmarc.example.com +short
# ส่ง Test Email ไป Gmail แล้วดู Header:
# Gmail → เปิด Email → More (⋮) → Show original
# ดูผลลัพธ์:
# SPF: PASS
# DKIM: PASS
# DMARC: PASS
BIMI (Brand Indicators for Message Identification)
BIMI คือมาตรฐานใหม่ที่แสดง Logo ของแบรนด์ ถัดจากชื่อผู้ส่งใน Email Client (เช่น Gmail, Apple Mail) ต้องมี DMARC p=quarantine หรือ p=reject ก่อนถึงจะใช้ BIMI ได้
# BIMI DNS Record:
# Host: default._bimi
# Type: TXT
# Value: v=BIMI1; l=https://example.com/logo.svg; a=https://example.com/vmc.pem
# ข้อกำหนด BIMI:
# 1. DMARC policy ต้องเป็น quarantine หรือ reject
# 2. Logo ต้องเป็น SVG Tiny PS format
# 3. VMC (Verified Mark Certificate) จาก CA ที่ได้รับอนุญาต (ไม่บังคับแต่แนะนำ)
# 4. Logo ต้อง Host บน HTTPS
Email Gateway Security
Email Gateway คืออะไร?
Email Gateway (SEG – Secure Email Gateway) คือ Layer เพิ่มเติมที่อยู่ระหว่าง Internet กับ Mail Server ช่วยกรอง Email อันตรายก่อนถึงกล่องจดหมาย
| ฟีเจอร์ | หน้าที่ | ตัวอย่าง Solution |
|---|---|---|
| Anti-Spam | กรอง Email ขยะ | SpamAssassin, Barracuda |
| Anti-Malware | ตรวจ Attachment อันตราย | ClamAV, Sophos |
| Anti-Phishing | ตรวจ URL อันตรายใน Email | Proofpoint, Mimecast |
| Sandboxing | เปิด Attachment ใน Sandbox ก่อน | FireEye, Palo Alto WildFire |
| DLP | ป้องกันข้อมูลรั่วไหลผ่าน Email | Microsoft DLP, Symantec |
| Encryption | เข้ารหัส Email ที่มีข้อมูลสำคัญ | TLS, S/MIME, PGP |
Anti-Spam Best Practices
สำหรับ IT Admin
- ตั้งค่า SPF + DKIM + DMARC ให้ครบ: ลดโอกาสถูก Spoof + Email ของคุณไม่ถูกส่งไป Spam
- ใช้ RBL/DNSBL: ตรวจสอบ IP ของผู้ส่งกับ Blacklist (Spamhaus, Barracuda)
- กำหนด Rate Limiting: จำกัดจำนวน Email ที่ส่งต่อชั่วโมง/วัน
- ใช้ Greylisting: ปฏิเสธ Email จาก IP ใหม่ครั้งแรก Legit Server จะส่งซ้ำ Spam Server มักไม่ส่งซ้ำ
- ตั้ง Reverse DNS (PTR Record): IP ของ Mail Server ต้องมี PTR Record ที่ตรงกับ Domain
- Monitor DMARC Reports: ตรวจสอบ Report ว่ามีใครพยายาม Spoof Domain ของคุณ
- อบรมพนักงาน: สอนให้รู้จัก Phishing Email และวิธีรายงาน
Monitoring DMARC Reports
ประเภท Report
| ประเภท | Tag | เนื้อหา | ความถี่ |
|---|---|---|---|
| Aggregate (RUA) | rua=mailto: | สรุป Email ทั้งหมดที่ใช้ Domain, ผลลัพธ์ SPF/DKIM/DMARC | ทุกวัน |
| Forensic (RUF) | ruf=mailto: | รายละเอียดของ Email ที่ Fail รวมถึง Header | ทุกครั้งที่ Fail |
# เครื่องมือวิเคราะห์ DMARC Reports:
# 1. DMARC Analyzer (dmarcanalyzer.com) — ฟรี/เสียเงิน
# 2. Postmark DMARC (dmarc.postmarkapp.com) — ฟรี
# 3. Valimail — Enterprise
# 4. Agari — Enterprise
# 5. PowerDMARC — SMB/Enterprise
#
# สิ่งที่ต้องดูใน Report:
# - IP ไหนส่ง Email จาก Domain ของคุณ?
# - Email ที่ Fail SPF/DKIM มาจากไหน?
# - มี Source ที่ Legitimate แต่ไม่ได้ Authorize หรือไม่?
# - มี Spoofing Attempt หรือไม่?
สรุป: Email Security Checklist สำหรับ IT Admin
| ลำดับ | งาน | สถานะ |
|---|---|---|
| 1 | ตั้งค่า SPF Record ให้ครบทุก Sending Server | [ ] |
| 2 | เปิดใช้ DKIM Signing + ใส่ DNS Record | [ ] |
| 3 | ตั้ง DMARC p=none เริ่ม Monitor | [ ] |
| 4 | ทดสอบด้วย mail-tester.com + MXToolbox | [ ] |
| 5 | วิเคราะห์ DMARC Report 2-4 สัปดาห์ | [ ] |
| 6 | แก้ไข Source ที่ Fail SPF/DKIM | [ ] |
| 7 | เปลี่ยน DMARC เป็น p=quarantine | [ ] |
| 8 | Monitor อีก 2-4 สัปดาห์ | [ ] |
| 9 | เปลี่ยน DMARC เป็น p=reject (Full Protection) | [ ] |
| 10 | พิจารณา BIMI สำหรับ Brand Visibility | [ ] |
Email Security ไม่ใช่เรื่องยาก แต่ต้องทำอย่างเป็นขั้นตอน เริ่มจาก SPF → DKIM → DMARC (none → quarantine → reject) ทดสอบทุกขั้นตอน Monitor Report อย่างสม่ำเสมอ แล้วองค์กรของคุณจะปลอดภัยจากภัยคุกคามทาง Email ได้อย่างมีประสิทธิภาพ