Setup Email on Centos

August 28, 2013

To setup email on Centos 6 run these commands

yum -y install sendmail mailutils
chkconfig --levels 235 sendmail on
service sendmail restart

To send a test email

echo "test message" | mail -s "test subject" [email protected]

Hosts File

Modify your hosts file and add $HOSTNAME.local to prevent issues (in example below we are using hostname monitor)

<your ip address>  monitor monitor.local
service sendmail restart

Why Do I Need a FQDN in Hosts File?

i see users post this over and over – “sendmail hangs” or “sendmail takes forever to load”

the problem is that sendmail is looking for a FQDN, and it is probably finding your hostname before localhost and localhost.localdomain

your host file entry should have your simple hostname after the others:

/etc/hosts localhost.localdomain localhost myhostname <— order matters!!!

if done this way, sendmail sees a FQDN for your loopback interface and will breeze right through.