send an email via bash terminal linux


sendemail works!
just enable when needed in this page :
https://www.google.com/settings/security/lesssecureapps

then you can do your silly stuff

 

SENDER="myaccount@gmail.com"
MAILTO="receiver@gmail.com"
PASSWORD="yoursillypassword"
TITLE="e-MAIL SENT WITH SENDMAIL"
MESSAGE="Hello this is a mail from my linux terminal"
sendemail -o tls=yes -f "$SENDER" -t "$MAILTO" -s smtp.gmail.com:587 -xu "$SENDER" -xp "$PASSWORD" -u "$TITLE" -m "$MESSAGE"

if you want add an attachment you need to do :

SENDER="myaccount@gmail.com"
MAILTO="receiver@gmail.com"
PASSWORD="yoursillypassword"
TITLE="e-MAIL SENT WITH SENDMAIL"
ATTACHMENT="/path/tofile"
MESSAGE="Hello this is a mail from my linux terminal"
sendemail -o tls=yes -f "$SENDER" -t "$MAILTO" -s smtp.gmail.com:587 -xu "$SENDER" -xp "$PASSWORD" -u "$TITLE" -m "$MESSAGE" -a "$ATTACHMENT"