Sub topic 8
Sending infrastructure: reverse DNS, TLS, and message format
This chapter assumes you can read DNS records, run dig, and read raw email headers. It also assumes you know the basic SMTP conversation (connect, EHLO, MAIL FROM, RCPT TO, DATA). Earlier chapters covered SPF, DKIM, and DMARC, which prove who is sending. This chapter covers the plumbing under those checks: whether the connecting server looks like a legitimate mail server, whether the connection is encrypted, and whether the message is built the way the standards say.
Why these checks exist
Spammers often send from hosts that were never set up as mail servers, such as compromised home machines, throwaway cloud instances, or hijacked IP ranges. Those hosts usually have no reverse DNS, no TLS support, and sloppy message construction. These basics cost a legitimate sender almost nothing, so receivers use them as cheap filters.
Gmail and Yahoo list these items next to authentication in their sender guidelines. Both ask for valid forward and reverse DNS on sending IPs, TLS for transmission, and messages formatted to the Internet Message Format standard (RFC 5322). Microsoft's published requirements for Outlook.com, Hotmail, and Live focus mainly on SPF, DKIM, DMARC, and sender hygiene. Even so, Microsoft's filters also penalize poorly configured infrastructure. Check each provider's current documentation, because the wording changes.
Reverse DNS and forward-confirmed reverse DNS
A PTR record maps an IP address back to a hostname. Ordinary (forward) DNS goes from name to address with an A or AAAA record. Reverse DNS goes the other way, using a special zone: 203.0.113.25 is looked up as 25.113.0.203.in-addr.arpa.
Receivers want forward-confirmed reverse DNS (FCrDNS). The check works like this:
- Look up the PTR record of the connecting IP and get a hostname.
- Look up the A or AAAA records of that hostname.
- Confirm that one of the results is the original IP.
If step 3 fails, the PTR record is not trustworthy. Anyone who controls an IP block can write any PTR value, but only the owner of the domain can make the matching A record point back.
Who controls the PTR record
You do not publish PTR records in your own domain's zone. The owner of the IP block controls the reverse zone. That is usually your ESP, cloud provider, or ISP. If you use a shared ESP IP, the ESP already handles this. If you run dedicated or self-hosted IPs, you must ask the IP owner to set the PTR, or use their control panel. AWS, for example, has a form for Elastic IPs.
Good practice for the setup:
- Use a hostname in a domain you control, such as
mta1.example.com, not the provider's generic name likeec2-203-0-113-25.compute.amazonaws.com. - Make the same hostname the one your server announces in
EHLO. Some filters compare the two. - Give each sending IP its own PTR record.
- Publish PTR records for IPv6 addresses too if you send over IPv6. A receiver that sees an IPv6 connection without reverse DNS may reject it. IPv6 sending is a common source of surprises because it is often enabled by default.
Checking it
# 1. PTR lookup for the sending IP
dig +short -x 203.0.113.25
# 2. Forward lookup of the name returned above
dig +short A mta1.example.com
# 3. Check what the server announces in EHLO
openssl s_client -starttls smtp -connect mta1.example.com:25 -crlf -quietIn the third command, type EHLO test.example.com once connected and read the response. The first line of the greeting also names the host.
You can script the FCrDNS test:
import socket
def fcrdns(ip):
"""Return (ok, hostname) for forward-confirmed reverse DNS."""
try:
hostname, _, _ = socket.gethostbyaddr(ip)
except (socket.herror, socket.gaierror):
return False, None
try:
_, _, addresses = socket.gethostbyname_ex(hostname)
except socket.gaierror:
return False, hostname
return ip in addresses, hostname
ok, name = fcrdns("203.0.113.25")
print(f"FCrDNS ok={ok} hostname={name}")gethostbyname_ex only returns IPv4 addresses. For IPv6 sending IPs, use socket.getaddrinfo with AF_INET6 instead. The documentation address in the example will print ok=False, which is the expected result for a placeholder.
TLS in transit
SMTP starts in plaintext. Servers upgrade the connection with the STARTTLS command, which switches the same connection to an encrypted channel. Gmail asks senders to use TLS when they transmit mail, and it marks messages delivered without it in the web interface. Outbound mail to Gmail over an unencrypted connection is a problem you can fix on your side.
Points to check:
- Your MTA must offer opportunistic TLS on outbound connections. In Postfix this means
smtp_tls_security_level = mayor stricter. - Use a modern protocol version. TLS 1.2 is the practical minimum, and TLS 1.3 is better. Receivers may drop connections from servers that only support TLS 1.0 or 1.1.
- If your MTA also accepts mail (for bounces and replies), its certificate should be valid, match the hostname, and not be expired.
# Postfix main.cf: enable opportunistic TLS and log it
smtp_tls_security_level = may
smtp_tls_loglevel = 1
smtp_tls_protocols = >=TLS1.2With smtp_tls_loglevel = 1, the mail log records the negotiated protocol and cipher for each delivery. Look for lines that say TLS connection established. Lines that say Untrusted or Anonymous TLS are normal for opportunistic mode, because the sender does not verify the recipient's certificate. The mail is still encrypted.
What TLS does not do
TLS protects the connection between two servers. It says nothing about who wrote the message. It is not a substitute for DKIM, and a message that passes through several hops can be encrypted on each hop and still be forged.
Message format
Receivers parse your message against RFC 5322. Violations lower your reputation even when authentication passes. The most common problems:
| Problem | Why it matters |
|---|---|
| Missing or invalid `Date` header | Required by the standard. Bad dates are a strong spam signal. |
| Missing `Message-ID` | Used for deduplication and threading. It should be unique and use your own domain after the `@`. |
| More than one address in `From` | Breaks DMARC evaluation in many receivers. Use one address. |
| Malformed addresses or stray whitespace | The message may be rejected with a 5xx syntax error. |
| Lines longer than 998 characters | The standard's hard limit. Use quoted-printable or base64 encoding for long lines. |
| HTML with no plain-text alternative | Gives spam filters less to judge, and some read the HTML-only pattern as a risk signal. |
| No `MIME-Version` header, or a wrong `Content-Type` | Receivers may misread the body. |
Here is a well-formed header block for a marketing message:
Date: Thu, 26 Nov 2026 13:45:00 +0000
From: Example News <[email protected]>
To: [email protected]
Subject: Our November update
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="b1_91c2"
List-Unsubscribe: <https://example.com/unsubscribe/abc123>
List-Unsubscribe-Post: List-Unsubscribe=One-ClickThe body then contains a text/plain part and a text/html part, in that order, with the boundary string from the header.
Do not impersonate large providers
Gmail's rules say you should not send mail with a From address at gmail.com from your own servers. Gmail publishes a DMARC policy of p=quarantine for its own domain, so such mail will be quarantined or rejected. Always send from a domain you own. The same applies to other consumer domains that publish DMARC enforcement, such as Yahoo's.
Putting the checks in order
A receiving server evaluates a connection in a rough sequence. The exact order and enforcement differ by provider, but this model helps when you debug.
Common errors
- Shared hostname mismatch. The PTR says
mta1.example.com, but the server saysEHLO localhost. Set the MTA'smyhostname(Postfix) or equivalent explicitly. - PTR set, forward record missing. The A record was never created, or points to a different IP after a migration.
- New IP after a migration. The old IP still has the PTR. Update reverse DNS on every IP that sends mail.
- TLS offered but broken. An expired certificate on the sending side is usually tolerated in opportunistic mode, but it can cause failures where the receiver enforces stricter policy.
- Template bugs. A marketing platform with a blank
Dateor a duplicateMessage-IDacross thousands of messages is a template or system bug, not a DNS problem.
Exercise
Your sending IP is 203.0.113.25. dig +short -x 203.0.113.25 returns mail.example.com., but dig +short A mail.example.com returns 203.0.113.99. Does this IP pass forward-confirmed reverse DNS, and what is the fix?
Show answer
It fails. FCrDNS requires the forward lookup of the PTR hostname to return the original IP, and here it returns a different one (203.0.113.99). Fix it by either changing the A record for mail.example.com to 203.0.113.25, or asking the IP owner to change the PTR to a hostname whose A record already points to 203.0.113.25. Also make the server's EHLO hostname match.
Exercise
A message is delivered over a fully encrypted TLS 1.3 connection and has a valid PTR record. Does that prove the message really came from the domain in the From header? Why or why not?
Show answer
No. TLS only protects the connection between two servers, and a valid PTR only shows the sending IP has reasonable reverse DNS. Neither ties the message to the From domain. SPF, DKIM, and DMARC alignment do that.