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"
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: