Send email from Centos to your gmail account —USING SSMTP

NB: i’m working with a centos 6 server called lab1.olivermel.com
a valid gmail account in my case mygmailaccount@gmail.com

a valid gmail password for the mygmailaccount@gmail.com which is mygmailpassword

You might have the need to send an email from your Centos/RedHat server to your gmail account.

Here’s a very quick “how-to”

On your centos server, download ssmtp

#yum install -y ssmtp

Next, we will edit /etc/ssmtp/ssmtp.conf and add the following lines (or edit to add lines)

root=mygmailaccount@gmail.com”
mailhub=smtp.gmail.com:587
RewriteDomain=gmail.com
UseSTARTTLS=YES
AuthUser=mygmailaccount
AuthPass=mygmailpassword
FromLineOverride=yes
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt
hostname=lab1.olivermel.com

Next, you will edit the following file, /etc/ssmtp/revaliases

where you will add the following

root:mygmailaccount@gmail.com:smtp.gmail.com:587

 

NB:
mygmailaccount has to be a valid gmail account
mygmailpassword has to be the password of the above account.

You can verify by sending a test email

echo “test 123” | ssmtp -vvv mygmailaccount@gmail.com

Leave a Reply

Your email address will not be published. Required fields are marked *