Topics: Red Hat / Linux, System Admin

Enabling sendmail on Linux

  • Make sure the relay host, e.g. the Exchange server, allows incoming email from your Linux server.
  • Make sure no firewall is blocking SMTP traffic from the Linux host. You can use nmap for this purpose:
    # nmap -sS
    (Replace "" for the actual SMTP server hostname of your environment).
  • Check it the DNS configuration is correct in /etc/resolv.conf and make sure you can resolve the hostname and its IP address reversely:
    # nslookup hostname
    # nslookup ipaddress
    (use the IP address returned by the first DNS lookup on the hostname to reversely lookup the hostname by the IP address).
  • Make a copy of and in /etc/mail.
  • Edit (add in the name of your SMTP server):
    define(`confTRUSTED_USER', `root')dnl
    define(`SMART_HOST', `')dnl
  • Then run:
    # make -C /etc/mail
  • Edit by modifying the "C{E}" line in Take any user listed on that line including root off that line, so mail sent from root gets masqueraded as well. Towards the bottom of file, there is a section for Ruleset 94. Make sure that after "R$+" there is ONE tab (no space, or multiple spaces/tabs):
    R$+ $@ $>MasqHdr $1
  • Clean out /var/spool/clientmqueue and /var/spool/mqueue (there may be lots of OLD emails there, we may not want to send these anymore).
  • Then restart sendmail:
    # service sendmail restart
    (or "service sendmail start" if it isn't running yet; check the status with: "service sendmail status").
  • Make sure that sendmail is started at system restart:
    # chkconfig sendmail on # chkconfig --list sendmail
  • Open a "tail -f /var/log/maillog" so you can watch any syslog activity for mail (of course there should be a "mail.*" entry in /etc/syslog.conf directing output to /var/log/maillog for this to work).
  • Send a test email message:
    # echo "test" | sendmail -v
    (and check that the email message is actually accepted for delivery in the verbose output).
  • Wait for the mail to arrive in your mailbox.

If you found this useful, here's more on the same topic(s) in our blog:

UNIX Health Check delivers software to scan Linux and AIX systems for potential issues. Run our software on your system, and receive a report in just a few minutes. UNIX Health Check is an automated check list. It will report on perfomance, capacity, stability and security issues. It will alert on configurations that can be improved per best practices, or items that should be improved per audit guidelines. A report will be generated in the format you wish, and the report includes the issues discovered and information on how to solve the issues as well.

Interested in learning more?