How to Configure the SMTP HELO/EHLO Name
Set the correct SMTP HELO/EHLO hostname in Postfix and Sendmail, configure FCrDNS records, and verify your mail server won't be rejected or spam-flagged.
Before you start
- ▸Root or sudo access on the mail server
- ▸A public static IP address with PTR record control (via hosting provider)
- ▸A registered domain with access to its DNS zone
- ▸Postfix or Sendmail installed and running
When your mail server opens an SMTP connection it must introduce itself with a HELO or EHLO command followed by a hostname. That hostname is checked by receiving servers in several ways: they compare it against the connecting IP's reverse DNS (PTR record), they may verify it resolves forward again to the same IP (Forward-Confirmed Reverse DNS, FCrDNS), and they use it as a spam signal. A misconfigured HELO name is one of the fastest ways to land in the junk folder or get outright rejected. This guide covers setting the correct HELO/EHLO name in Postfix and Sendmail, wiring up the required DNS records, and verifying everything holds together.
How HELO/EHLO Affects Deliverability
The SMTP greeting looks like this on the wire:
EHLO mail.example.com
Receiving MTAs run several checks against that string:
- Syntax check – must be a fully-qualified domain name (FQDN) or an address literal. Bare hostnames like
localhostorubuntufail immediately at strict receivers. - Forward DNS check – the EHLO name must resolve to at least one A or AAAA record.
- FCrDNS check – the PTR record for your sending IP must point to a hostname that resolves back to the same IP. This is the one most often misconfigured on cloud VMs where the PTR is set by the hosting provider.
- Consistency check – many filters add penalty points when the EHLO name differs from the hostname in the
Received:header or from the domain in the envelopeMAIL FROM.
None of these are hard SMTP requirements under RFC 5321, but in practice major receivers (Gmail, Outlook, Yahoo) treat failures as strong spam signals.
Prerequisites: DNS Records First
Before touching MTA configuration, make sure your DNS is correct. Assume your server's public IP is 203.0.113.10 and you want the mail hostname to be mail.example.com.
A record
Add or confirm this in your DNS zone for example.com:
mail.example.com. IN A 203.0.113.10
PTR record (reverse DNS)
Log in to your hosting or IP provider's control panel and set the PTR for 203.0.113.10 to mail.example.com. On VPS providers this is usually under "Networking" or "IP Management". You cannot set PTR records in your own zone file unless you have been delegated the reverse zone.
Verify both records propagate
dig +short mail.example.com A
dig +short -x 203.0.113.10
Both commands should return each other's value. If they do not match, fix DNS before continuing — MTA configuration cannot compensate for broken FCrDNS.
Configuring the EHLO Name in Postfix
Postfix is the default MTA on most modern distributions. The EHLO name comes from myhostname in /etc/postfix/main.cf.
Set myhostname and related parameters
sudo postconf -e 'myhostname = mail.example.com'
sudo postconf -e 'mydomain = example.com'
sudo postconf -e 'myorigin = $mydomain'
myhostname is what Postfix uses verbatim in the EHLO banner. myorigin controls the domain appended to unqualified sender addresses — keeping it consistent with mydomain prevents envelope/EHLO mismatches.
Check the SMTP banner
The banner is also visible to receivers and should match:
sudo postconf smtpd_banner
The default is $myhostname ESMTP $mail_name, which is fine. Avoid advertising software versions to reduce fingerprinting:
sudo postconf -e 'smtpd_banner = $myhostname ESMTP'
Reload Postfix
sudo systemctl reload postfix
Verify the live EHLO
openssl s_client -starttls smtp -connect mail.example.com:587 2>/dev/null | head -20
Look for a line like 250-mail.example.com near the top of the output. That confirms what Postfix is advertising. You can also use plain telnet on port 25 if TLS is not yet configured:
telnet mail.example.com 25
Type EHLO testclient.example.com and the server should respond with 250-mail.example.com as the first capability line.
Configuring the EHLO Name in Sendmail
Sendmail is less common on new deployments but still present on some RHEL-family and legacy systems. Its EHLO name derives from the j macro, which is set from the system hostname unless overridden.
Set the hostname macro in sendmail.mc
Edit /etc/mail/sendmail.mc (Debian/Ubuntu: /etc/sendmail.mc). Find or add the Dj macro:
sudo grep -n 'Dj\|confDOMAIN_NAME' /etc/mail/sendmail.mc
If absent, add before the MAILER lines:
echo "define(\`confDOMAIN_NAME', \`mail.example.com')dnl" | \
sudo tee -a /etc/mail/sendmail.mc
Regenerate sendmail.cf and restart
# Fedora/RHEL
sudo make -C /etc/mail
sudo systemctl restart sendmail
# Debian/Ubuntu
sudo sendmailconfig
sudo systemctl restart sendmail
Verify
telnet localhost 25
The greeting banner should show your FQDN. Sendmail also logs the EHLO value in /var/log/maillog (Fedora/RHEL) or /var/log/mail.log (Debian/Ubuntu) for every outbound connection.
System Hostname Alignment
Both Postfix and Sendmail fall back to the OS hostname when no explicit value is set. Keep it consistent to avoid surprises after reboots or config resets.
sudo hostnamectl set-hostname mail.example.com
Confirm:
hostnamectl status
The output should show Static hostname: mail.example.com. Also check /etc/hosts to ensure the FQDN maps to the correct IP and not just 127.0.1.1 (common on Ubuntu cloud images), which can confuse MTA hostname detection:
grep mail.example.com /etc/hosts
It should read:
203.0.113.10 mail.example.com mail
End-to-End Verification
Use MXToolbox or mail-tester.com for a quick external check, but you can do it from the command line too.
Check what a remote server sees
swaks --to [email protected] --server mail.example.com --port 587 \
--auth-user [email protected] --auth-password yourpass --tls
swaks (Swiss Army Knife for SMTP) is available in all major distro repos. It prints the full SMTP conversation including EHLO exchange so you can confirm exactly what name your server advertises.
Check FCrDNS with a one-liner
IP=203.0.113.10
PTR=$(dig +short -x $IP | sed 's/\.$//')
FWD=$(dig +short $PTR A)
echo "IP=$IP PTR=$PTR FWD=$FWD"
[ "$IP" = "$FWD" ] && echo "FCrDNS OK" || echo "FCrDNS FAIL"
Troubleshooting
- Postfix still shows old hostname after reload – Run
sudo postfix checkfirst; errors prevent config reloads from taking effect. Also verify withpostconf myhostnamethat the value changed. - PTR record not updating – PTR changes at cloud providers can take up to 24 hours and sometimes require a support ticket. Use
dig @8.8.8.8 -x <IP>to bypass local resolver caching when checking propagation. - FCrDNS passes but mail still bounced – Check SPF and DKIM. A correct EHLO/FCrDNS is necessary but not sufficient; most modern receivers also require a valid SPF record and a DKIM signature.
- Multiple outbound IPs – If your server has more than one public IP and Postfix selects the wrong source address, set
smtp_bind_address = 203.0.113.10inmain.cfto pin outbound connections to the IP whose PTR matchesmyhostname. - localhost or ubuntu appearing in EHLO – The OS hostname is not set to an FQDN. Run
hostname -f; if it returns a bare name, fix it withhostnamectlas shown above and restart the MTA.
Frequently asked questions
- Does the EHLO name have to match the envelope From domain?
- No, they are separate identifiers — the EHLO name identifies the MTA host, while the envelope From identifies the sender address. However, having them share the same parent domain reduces spam scoring penalties at many receivers.
- My server is behind NAT. What EHLO name should I use?
- Use the public FQDN whose A record points to your public IP and whose PTR matches. Also set smtp_bind_address or use masquerade settings so the MTA sources connections from the correct IP. The internal RFC 1918 address is irrelevant to the EHLO check.
- Will a wrong EHLO name cause immediate rejection or just increase spam score?
- It depends on the receiver. Strict servers like some corporate gateways reject at EHLO if FCrDNS fails (550 response). Most large consumer providers (Gmail, Outlook) accept the message but weight it heavily in spam classification.
- Can I use an IP address literal as the EHLO argument instead of a hostname?
- RFC 5321 permits address literals like EHLO [203.0.113.10], but in practice most anti-spam systems treat an IP literal EHLO as a strong spam indicator. Always use a proper FQDN.
- Do I need to change anything if I add DKIM later?
- No. DKIM signing is configured separately and does not affect the EHLO name. The EHLO hostname, SPF record, and DKIM signature are independent layers that together establish sender reputation.
Related guides
Configure Prometheus Alertmanager
Configure Prometheus Alertmanager with routing trees, receivers, inhibition rules, grouping, Go templates, and PagerDuty/Slack on-call integrations.
Build an Intranet Server on Linux
Set up a complete small-office intranet on one Linux box: Nginx web server, dnsmasq local DNS, Samba file sharing, and a Wiki.js team wiki.
Build an nftables Firewall Script
Build a complete nftables firewall from scratch: tables, chains, sets, default-deny input policy, service allowlisting, and persistent systemd configuration.
Caddy as a Reverse Proxy
Set up Caddy as a reverse proxy with automatic HTTPS, load balancing, WebSocket passthrough, reusable snippets, and header control — no certbot required.