Tuesday, December 5, 2017

Configure ssmtp to use gmail SMTP relay on CentOS

1. Install ssmtp rpm as,

#yum install ssmtp

2. Now edit ssmtp.conf file as,

#vim /etc/ssmtp/ssmtp.conf

root=XXX@gmail.com
mailhub=smtp.gmail.com:465
AuthUser=XXXX@gmail.com
AuthPass=<Password of gmail account>
FromLineOverride=YES
UseTLS=YES
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt

3. After this, make ssmtp default mta as,

#alternatives --config mta

it will ask to choose mta, here select the ssmtp and enter.


4. Now send the mail as,

#mail -s "SUBJECT" xxxxx@abc.com