Configuring Custom HELO/EHLO Hostname for Outbound SMTP in Sendmail


4 views

When your sendmail server communicates with remote SMTP servers, it identifies itself through HELO/EHLO commands during the initial SMTP handshake. This hostname should properly resolve to your mail server's IP address to avoid being flagged as potential spam. Many email providers perform reverse DNS (rDNS) lookups to verify this information.

There are two primary ways to set the HELO/EHLO identity in sendmail:

1. Using sendmail.mc Configuration

The most maintainable approach is to modify your sendmail.mc file and rebuild the configuration. Add or modify these lines:

define(confDOMAIN_NAME', mail.yourdomain.com')dnl
define(confHELO_NAME', mail.yourdomain.com')dnl

After making changes, rebuild your sendmail.cf file:

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
service sendmail restart

2. Directly Editing sendmail.cf

For quick testing, you can directly edit sendmail.cf (not recommended for production):

# Find and modify these lines in sendmail.cf
Djmail.yourdomain.com
# or
Dnmail.yourdomain.com

After configuration, verify your settings by sending a test email while monitoring the SMTP conversation:

telnet localhost 25
EHLO test
quit

Or examine the SMTP headers of received messages to see what hostname your server presents.

If your HELO/EHLO changes aren't taking effect:

  • Ensure you've restarted sendmail after configuration changes
  • Check for multiple conflicting definitions in sendmail.mc
  • Verify DNS settings - the HELO hostname should have proper A and PTR records
  • Monitor mail logs for errors (/var/log/maillog typically)

For complex setups, you might need to configure masquerading or per-interface HELO settings:

FEATURE(masquerade_envelope')dnl
FEATURE(masquerade_entire_domain')dnl
MASQUERADE_AS(yourdomain.com')dnl

Remember that HELO/EHLO settings are just one part of proper email server configuration. Ensure your SPF, DKIM, and DMARC records are also properly configured for maximum deliverability.


When establishing SMTP connections, the sending server identifies itself through HELO/EHLO commands. Proper configuration prevents being flagged as spam and ensures successful delivery. The default behavior often uses the server's hostname, which might not match your mail domain.

The primary configuration file is typically found at:

/etc/mail/sendmail.mc

On some systems, you may need to edit:

/etc/mail/sendmail.cf

Add this line to your sendmail.mc file before rebuilding the configuration:

define(confHELO_NAME', mail.yourdomain.com')dnl

Alternatively, for domain-specific HELO strings:

FEATURE(masquerade_envelope')dnl
FEATURE(masquerade_entire_domain')dnl
MASQUERADE_AS(yourdomain.com')dnl
MASQUERADE_DOMAIN(yourdomain.com')dnl

After making changes, rebuild and restart:

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
service sendmail restart

Test your configuration with telnet:

telnet localhost 25
EHLO test

The response should show your configured hostname.

If changes don't take effect:

  • Check for syntax errors in .mc file
  • Verify the configuration was properly rebuilt
  • Ensure proper file permissions
  • Check system logs for errors

When configuring HELO:

  • Use a valid FQDN that resolves to your mail server
  • Avoid generic names that might trigger spam filters
  • Ensure reverse DNS matches your HELO string