1. Install SSMTP

sudo yum install ssmtp

2. Edit config file of ssmtp

#open editor
sudo mcedit /etc/ssmtp/ssmtp.conf

#change mailhub to
mailhub=smtp.gmail.com:587

#change this line to
UseTLS=YES

#add these lines
UseSTARTTLS=YES
AuthUser=SOME-USERNAME@gmail.com
AuthPass=PASSWORD-OF-USER-ABOVE

#uncomment this line
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt

3. Send a email using ssmtp

ssmtp receiver@some.domain
Subject: ENTER SUBJECT HERE
CONTENT LINE 1
CONTENT LINE 2
...
^d

Reference:

https://tecadmin.net/send-email-smtp-server-linux-command-line-ssmtp/

Advertisements