Get an app password from here
Add the following lines to /etc/ssmtp/ssmtp.conf:
root=myusername@gmail.com
mailhub=smtp.gmail.com:465
FromLineOverride=YES
AuthUser=myusername@gmail.com
AuthPass=passwordcreatedfromabove
UseTLS=YES
Send a test email:
echo "Testing...1...2...3" | ssmtp emailaddress@gmail.com
Sending with an attachment
echo -e "to: receiver@domain.tld\nsubject: subject\n"| (cat - && uuencode /path/to/attachment attachment.name) | ssmtp receiver@gmail.com
apt-get install sharutils to get uuencode command