Using ssmtp to send mail using gmail.

First install the package ssmtp using the command:

1
sudo yum install ssmtp

Open the configuration file for ssmtp as root user:

1
vim /etc/ssmtp/ssmtp.conf

Make the following changes to the configuration file:

root=username@gmail.com
mailhub=smtp.gmail.com:587
hostname=username@gmail.com
UseSTARTTLS=YES
AuthUser=username
AuthPass=password
FromLineOverride=yes

In order to make the default (root) “from” field be the server name,
edit the /etc/ssmtp/revaliases file as root user :

1
vi /etc/ssmtp/revaliases

And add into it the desired translation which in our Gmail examples case
will be:

root:test@example.com:smtp.gmail.com

and time to test:

1
echo "Amit Agarwal"|ssmtp <email id>

If this does not work, then you can try with -v or -vv or -vvv for ssmtp command.

Enhanced by Zemanta