Friday, October 7, 2011

Why Can't I get System Mail

RHEL 5.7
While configuring logwatch I found I was not getting any system mail.
# mail
Result: no mail for root

Even when I sent a message I got nadda

I had errors of these sorts in /var/log/maillog  (system is offline so these are paraphrased)

p97Hblahblah: to=root, delay=00:00:00, xdelay=blah, mailer=relay, , pri=blah, relay=[127.0.0.1], dsn=5.0.0, stat=Service unavailable

and

My unqualified host name (localhost) unknown; sleeping for retry


After several hours of Googlin-around I stumbled on a simple hint to fix both error types:

Fix the host file
So I did

 On the line where your loopback IP is listed (the top entry) make sure your system hostname and localhost.localdomain are listed

127.0.0.1   local localhost.localdomain my-hostname

Restart sendmail and errors were gone.  Also fixed the extremely slow sendmail service start up, was waiting 5+ minutes now it starts right up.

1 comment:

  1. Follow-up to this post. I was having a problem with rsyslog sending logs to a central server. On the central server log entires from client systems would show localhost instead of the host name making the logs unusable. In the process of troubleshooting I noticed that if issued the command hostname I would get the proper name of the server but if I issued hostname --fqdn I would get localhost.localdomain. it turned out having the host name listed on the 127.0.0.1 line in /etc/hosts was causing that.
    I removed the hostname from that line and #hostname --fqdn would return the correct hostname.

    This did not fix my rsyslog issue but adding the server ip info to the local DNS server did fix it. Probably can achieve the same by adding the servers it the hosts file on the central log server.

    ReplyDelete