Step 1 - Reference the fedora repo as centos does not include ssmtp
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
Step 2 - Install ssmtp
# yum install ssmtp
Step 3 - Configure ssmtp to use gmail to send email
# vi /etc/ssmtp/ssmtp.conf
Then insert the following text:
# # /etc/ssmtp.conf -- a config file for sSMTP sendmail. # # See the ssmtp.conf(5) man page for a more verbose explanation of the # available options. # root=This email address is being protected from spambots. You need JavaScript enabled to view it. mailhub=smtp.gmail.com:465 AuthUser=This email address is being protected from spambots. You need JavaScript enabled to view it. AuthPass=yourpassword RewriteDomain=yourdomain.com FromLineOverride=YES UseTLS=YES
Step 4 - Rename sendmail
# service sendmail stop # chkconfig sendmail off # mv /usr/sbin/sendmail /root # ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
That's it. Now test it.
# echo "This is the message body" | mail -s "This is the message subject" This email address is being protected from spambots. You need JavaScript enabled to view it.
Very useful indeed!