Urgent.News

What's breaking now, across thousands of outlets.

World

SPF, DKIM, DMARC Done Right: A Practical Email Authentication Checklist Before Your OTP Emails Land in Spam

Tuần này trên HN có tin Spamhaus siết yêu cầu với email sender từ tháng 11. Nếu bạn để ý thì đây không phải chuyện mới: Gmail và Yahoo đã bắt bulk sender phải có SPF, DKIM, DMARC từ tháng 2/2024, và Outlook cũng làm tương tự từ tháng 5/2025. Mình đã thấy khá nhiều startup Việt Nam gửi OTP, hóa đơn, email reset password qua Amazon SES hoặc Postfix tự dựng. Mọi thứ vẫn chạy ổn cho đến một ngày CS…

As of November, Spamhaus has been requesting email senders to implement SPF, DKIM and DMARC. Major email providers like Gmail, Yahoo and Outlook have mandated these authentication protocols for bulk senders since February 2024 and May 2025 respectively. Many Vietnamese startups using Amazon SES or self-hosted Postfix to send OTP, invoices and password reset emails have encountered issues where OTPs fail to reach users' inboxes.

Upon reviewing server logs, SMTP returns a "250 OK" response, but emails end up in spam folders or are rejected entirely.

The objective of this article is to provide a practical checklist for auditing an email sending domain, complete with a Python script for automated checks. The receiving server actually verifies three mechanisms: SPF checks the IP address against the domain's authorized list in the envelope sender (MAIL FROM / Return-Path), DKIM adds a digital signature to the email header and body, and DMARC combines SPF and DKIM results while aligning the email's From: address with the domain in the record.

A common mistake is using an ESP provider's "no-reply@shopabc.vn" header while setting the Return-Path to bounce@amazonses.com. SPF will pass in this case, but the domain alignment fails. DMARC will fail if the email is signed by the ESP's domain rather than the sender's. To resolve this, configure a custom MAIL FROM domain (e.g., bounce.shopabc.vn) and use Easy DKIM or custom DKIM with the domain as the selector.

A minimum DNS record set for sending domains through SES or Google Workspace should include:

1. SPF: v=spf1 include:_spf.google.com include:amazonses.com -all (only one SPF record per domain)

2. DKIM: 2048-bit key, selector set by the ESP (e.g., s1._domainkey.shopabc.vn)

3. DMARC: p=none, rua=mailto:dmarc@shopabc.vn, adkim=r, aspf=r, pct=100

Quick verification can be done with dig commands, such as:

- dig +short TXT shopabc.vn

- dig +short TXT _dmarc.shopabc.vn

- dig +short TXT s1._domainkey.shopabc.vn

- dig +short -x 203.0.113.10 (replacing with your IP)

Common pitfalls include having two or more SPF records, which results in PermError, or using outdated 1024-bit DKIM keys from 2015. It's recommended to rotate to 2048-bit keys and host your own PTR records if using a self-hosted SMTP server.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in World

More from Monday 16 November →