When configuring Sendmail to use an external SMTP server (commonly called a "smart host"), the error Host unknown (Name server: [IP]: host not found)
typically indicates DNS resolution issues. Even though you can ping the IP address, Sendmail performs additional verification steps.
For CentOS 5 (also applicable to modern systems with adjustments):
# Edit sendmail.mc
define(SMART_HOST', [10.1.1.30]')dnl # Brackets bypass DNS lookup
define(RELAY_MAILER_ARGS', TCP $h 587')dnl # For Exchange port
define(ESMTP_MAILER_ARGS', TCP $h 587')dnl
For authenticated relays (Exchange often requires this):
# Create auth info file
echo 'AuthInfo:10.1.1.30 "U:your_username" "P:your_password" "M:PLAIN"' > /etc/mail/authinfo
makemap hash /etc/mail/authinfo.db < /etc/mail/authinfo
chmod 600 /etc/mail/authinfo*
After rebuilding Sendmail configuration:
make -C /etc/mail
service sendmail restart
echo "Test" | mail -s "SMTP Test" recipient@domain.com
- Check connectivity:
telnet 10.1.1.30 25
- Verify DNS:
host 10.1.1.30
and reverse lookup - Inspect logs:
tail -f /var/log/maillog
For complex Exchange environments:
define(SMART_HOST', mail.company.com')dnl
define(confAUTH_MECHANISMS', EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(authinfo', Hash -o /etc/mail/authinfo.db')dnl
When configuring Sendmail to use an external SMTP server as a relay host, the error Host unknown (Name server: 10.1.1.30: host not found)
typically indicates a DNS resolution problem. Even though the IP is pingable, Sendmail performs additional hostname verification.
Here's how to properly configure Sendmail to relay through your Exchange server:
# Edit your sendmail.mc file
FEATURE(nocanonify', canonify_hosts')dnl
define(SMART_HOST', [10.1.1.30]')dnl
define(confDOMAIN_NAME', yourdomain.com')dnl
define(confDELIVERY_MODE', background')dnl
The square brackets around the IP address tell Sendmail to skip DNS lookups:
[10.1.1.30]
- Direct IP connection without hostname resolutionFEATURE(nocanonify')
- Prevents Sendmail from modifying addresses- Ensure your mail server accepts relaying from this IP
If your Exchange server requires authentication:
# Create/Edit /etc/mail/authinfo
AuthInfo:10.1.1.30 "U:yourusername" "P:yourpassword" "M:LOGIN"
# Generate the auth database
makemap hash /etc/mail/authinfo.db < /etc/mail/authinfo
- Rebuild your Sendmail configuration:
make -C /etc/mail
- Restart Sendmail:
service sendmail restart
- Test your configuration:
echo "Test" | mail -s "Test Subject" recipient@example.com
If emails still don't go through:
- Check
/var/log/maillog
for detailed error messages - Verify network connectivity:
telnet 10.1.1.30 25
- Test SMTP authentication separately if configured
Remember to adjust firewall settings if necessary to allow outbound SMTP traffic (port 25) to your Exchange server.