Sub topic 6
Reverse DNS and HELO hostname
This chapter assumes you can read DNS records, know what an MTA is, and have access to the DNS zone of your sending domain. You also need a way to set the PTR record for your sending IP. That is usually done at your hosting provider or ISP, not in your own zone.
Why receivers check the sending IP's identity
When your server connects to a mailbox provider, the provider sees only an IP address and whatever the server announces about itself. A new IP has no history. Before any content or reputation is evaluated, receivers run cheap checks on whether the IP looks like a real, intentionally configured mail server. Reverse DNS is one of the first.
Reverse DNS maps an IP address back to a hostname. The record that holds this mapping is a PTR record. A forward lookup turns a name into an IP (an A or AAAA record). A reverse lookup does the opposite.
Spammers often send from compromised machines or temporary cloud instances that have no PTR record, or a generic one such as 203-0-113-25.dynamic.isp.example. Many receivers therefore treat a missing or generic PTR as a strong negative signal. Some reject the connection outright. Others accept it but weigh it against you during a period when you have no reputation to offset it.
The three names that should agree
Three separate names identify a sending server, and they are set in three different places.
| Name | Where it is set | What it is |
|---|---|---|
| PTR hostname | Reverse zone, controlled by the IP owner | The name the IP resolves to |
| HELO/EHLO hostname | MTA configuration | The name your server announces at the start of the SMTP session |
| Forward A record | Your DNS zone | The IP that the hostname resolves to |
The goal is a closed loop, called forward-confirmed reverse DNS (FCrDNS):
- The sending IP has a PTR record pointing to
mail.example.com. mail.example.comhas an A record pointing back to the same IP.- The MTA announces
mail.example.comin its EHLO command.
The EHLO name does not have to equal the PTR name for delivery to work, but a mismatch is a common reason for scoring penalties, and it costs nothing to avoid. Use one hostname for all three.
Setting the PTR record
You cannot add a PTR record in your own domain's zone. Reverse zones such as 25.113.0.203.in-addr.arpa belong to whoever owns the IP block. Where you set it depends on how you obtained the IP:
- With a dedicated IP at an email service provider, the provider usually sets the PTR for you, often using a hostname you supply. Ask which name they use, and whether they let you choose it.
- With a cloud or VPS host, there is typically a control panel field or support request for "reverse DNS" on each IP.
- With an IP block assigned by an ISP or colocation provider, you submit a request, or the provider delegates the reverse zone to you.
- With a shared IP, you do not control the PTR. The provider's hostname is used, so there is nothing for you to configure.
Choose a hostname in your own domain, ideally in the sending subdomain from the earlier chapter, such as mail.example.com. A name in a domain you control lets you publish the matching A record yourself. Avoid hostnames that look like consumer-style generated names, because many filters pattern-match those.
On IPv6, the same rule holds, with a PTR under ip6.arpa and an AAAA record for the forward direction. Several providers apply stricter checks to IPv6 senders, so do not skip it if you send over IPv6.
Matching A records and one IP per name
Publish the forward record in your zone:
; Forward record for the MTA hostname
mail.example.com. IN A 203.0.113.25If you send from several IPs, give each its own PTR hostname and its own A record, for example mta1.example.com and mta2.example.com. A single PTR record per IP is the safe norm. Multiple PTR records on one IP are legal but confuse some checkers, so avoid them.
Keep the PTR hostname stable. Changing it means the IP presents a new identity to receivers, which weakens whatever history you have built. Decide the name before the first send, and do not rename it during the warm-up.
Configuring the EHLO hostname
The HELO or EHLO command is the first thing your MTA says after connecting. It should carry a fully qualified domain name that resolves to the sending IP. A bare name such as localhost, a raw IP without brackets, or an internal name like server01.local is a common cause of rejection.
Each MTA has its own setting:
# Postfix: set the announced hostname in main.cf
postconf -e 'myhostname = mail.example.com'
postconf -e 'smtp_helo_name = mail.example.com'
systemctl reload postfix
# Exim: in the main configuration, set
# primary_hostname = mail.example.com
# or, to change only the outbound name, set helo_data on the smtp transport.In Postfix, myhostname sets the system identity, and smtp_helo_name controls what is sent in outbound EHLO. Setting both avoids surprises if another setting overrides one of them. If you use a hosted email service, this is handled for you, and you can skip the MTA configuration.
The EHLO name is also what receivers use when they evaluate SPF for the HELO identity. A message with an empty return path (a bounce) is checked against the HELO name, so the name needs to be covered by an SPF record. The example zone from the authentication chapter publishes an SPF record for mail.example.com, which covers this case when the EHLO name is mail.example.com.
Verifying the setup
Check all three parts before the first send. These commands use the sample IP and hostname from this tutorial. Replace them with yours.
# 1. Reverse lookup: which hostname does the IP return?
dig +short -x 203.0.113.25
# 2. Forward lookup: does that hostname return the same IP?
dig +short A mail.example.com
# 3. Check what your MTA actually announces
openssl s_client -connect mail.example.com:25 -starttls smtp -crlf </dev/null 2>/dev/null | head -n 5The first command should print mail.example.com. and the second should print 203.0.113.25. The third connects to your server, and the greeting banner on the first line of output shows the hostname your MTA presents. Run it from a machine that can reach port 25, since many networks block outbound port 25.
You can also run the loop as a script, which is useful in a pre-send checklist:
import socket
import sys
def check_fcrdns(ip):
"""Return (ok, hostname) after a reverse lookup and a forward confirmation."""
try:
hostname, _, _ = socket.gethostbyaddr(ip)
except socket.herror:
return False, None
try:
forward_ips = {info[4][0] for info in socket.getaddrinfo(hostname, None)}
except socket.gaierror:
return False, hostname
return ip in forward_ips, hostname
if __name__ == "__main__":
ip = sys.argv[1] if len(sys.argv) > 1 else "203.0.113.25"
ok, hostname = check_fcrdns(ip)
if hostname is None:
print(f"FAIL: {ip} has no PTR record")
elif ok:
print(f"OK: {ip} -> {hostname} -> {ip}")
else:
print(f"FAIL: {ip} -> {hostname}, but the hostname does not resolve back to {ip}")Common errors
- No PTR record. The most frequent cause of immediate rejection on a new IP. Request it from the IP owner before anything else.
- PTR points to a name with no A record. The reverse lookup succeeds but the forward confirmation fails. Publish the A record.
- PTR is a generic ISP name. The loop closes, but filters recognize the pattern and penalize it. Replace it with a hostname in your own domain.
- EHLO says one name, PTR says another. Delivery may work, but you add avoidable risk. Align them.
- DNS caching after a change. A new PTR can take time to propagate, and negative caching may hold an old "no record" answer. Wait for the TTL before concluding that the change failed, and test against a public resolver such as
1.1.1.1. - Different IPs for outbound mail and the hostname. If your outbound traffic leaves through a NAT gateway or a different interface than you expect, the receiver sees another IP. Confirm the source IP in the headers of a test message.
Exercise
Exercise
You are about to warm up the dedicated IP 198.51.100.40 for the subdomain mail.example.org. dig +short -x 198.51.100.40 prints static-198-51-100-40.hosting.example.net., and your Postfix smtp_helo_name is localhost. List the changes you need to make before the first send, and who makes each one.
Show answer
First, ask the IP owner (your hosting provider) to change the PTR record to mail.example.org, because the reverse zone belongs to them and the current name is a generic hosting name. Second, publish an A record mail.example.org. IN A 198.51.100.40 in your own zone so the forward lookup confirms the reverse one. Third, set myhostname and smtp_helo_name to mail.example.org in Postfix and reload it, because localhost is not a valid public EHLO name. Finally, rerun the dig commands and confirm that the PTR returns mail.example.org. and the A lookup returns 198.51.100.40.
Exercise
A colleague says the EHLO name only matters for the SMTP greeting and that a mismatch with the PTR record is harmless. Give two reasons the match is still worth enforcing.
Show answer
Receivers score a mismatch between the PTR name and the EHLO name as a sign of a misconfigured or untrustworthy server, and a new IP has no good history to offset that penalty. Also, SPF is evaluated against the EHLO name for bounce messages with an empty return path, so the EHLO name must be a real hostname covered by an SPF record. Using one name for PTR, A record and EHLO removes both risks at no cost.