I wanted to send email reports from my computers. For that, the easiest is to create additional Gmail account (so your private email is safe) and set-up SSMTP:
sudo apt-get install ssmtp mailutils
Configure SSMTP: comment all lines in /etc/ssmtp/ssmtp.conf and add at the end (replacing HOSTNAME/USER/PASSWORD with your info):
Then, allow access from less secure apps to created Gmail account and enable one-time sign-in for new app without captcha. It’s strongly recommended not to use your private account for that purpose!
And send emails:
echo "email body" | mail -s "Test email from "`hostname` SOMEUSER@gmail.com
Note, this works perfectly fine in Ubuntu, as well as in Raspberry Pi.