Click here to Skip to main content
Click here to Skip to main content

Send Email from Command Line using GMail Account

By , 9 Jul 2012
 

Introduction

The script sends email from command line (MS-DOS) using GMail account.

Background

Download mailsend.exe from here.

Using the Code Examples

Plain Text Email/SMS via SSL

mailsend.exe -to anyemail@gmail.com  
-from myemail@gmail.com  -ssl -smtp smtp.gmail.com -port 465 -sub 
"The subject line test %time%" -M "This is body text of the message. 
%date% %time% sending. SD." +cc +bc -q -auth-plain -user "win4me" 
-pass "secret" 

Plain Text Email/SMS with Name of sender (via STARTTLS)

mailsend.exe -to anyemail@gmail.com  
-name "Automation" -from myemail@gmail.com -starttls -smtp smtp.gmail.com 
-port 587 -sub "The subject line test %time%" 
-M "This is body text of the message. %date% %time% sending. 
SD." +cc +bc -q -auth-plain -user "win4me" -pass "secret" 

Using default env variable instead of - pass

set SMTP_USER_PASS=secret 
<pre>mailsend.exe -to anyemail@gmail.com  
-from myemail@gmail.com  -ssl -smtp smtp.gmail.com -port 465 
-sub "The subject line test %time%" 
-M "This is body text of the message. %date% %time% sending. 
SD." +cc +bc -q -auth-plain -user "win4me"  

Attached image to email

mailsend.exe -to anyemail@gmail.com 
-from myemail@gmail.com  -ssl -smtp smtp.gmail.com -port 465 -sub "
Mail with attachment %time%" -M "This is body text of the message. 
%date% %time% sending. SD." +cc +bc -q -auth-plain -user "win4me" 
-pass  "secret"  -attach "C:\imagefile.jpg,image/jpg" 

In-line image in email body

mailsend.exe -to anyemail@gmail.com 
-from myemail@gmail.com  -ssl -smtp smtp.gmail.com -port 465 
-sub "Mail with inlime image %time%" -M "This is body text of the message. 
%date% %time% sending. SD." +cc +bc -q -auth-plain -user "win4me" 
-pass  "secret"  -attach "C:\imagefile.jpg,image/jpg,i"  

For more options, see:

mailsend -h
mailsend examples  

History

  • 07/08/2012: Originally posted

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Jack of AT
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 4memberCarlos Luis17 Jul '12 - 6:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 10 Jul 2012
Article Copyright 2012 by Jack of AT
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid