Install
sudo apt-get install ssmtp mailutils
Configure
edit file sudo nano /etc/ssmtp/ssmtp.conf
root=username@gmail.com mailhub=smtp.gmail.com:465 rewriteDomain=gmail.com AuthUser=username AuthPass=password FromLineOverride=YES UseTLS=YES
Test
ssmtp recipient@gmail.com < text.txt
mail -s "test" recipient@gmail.com < text.txt