Every once in a while, I’ve run into the need to send an email via the command line. Often, this is during make scripts, or other long processing batch jobs. I’ve almost always ended up succumbing to “net send” and being done with it, but that’s not an option anymore with Vista. The good ol’ (and much maligned) Messenger service is no more under Vista and Server 2008.
So, I need to send an email via command line.
There’s piles of little email apps like this floating around, but most don’t support TLS, secure sockets or authenticated smtp access, which, for better or worse, is what GMail requires now.
After a good deal of searching, I ended up coming across the very nice (and free), MailSend utility by Muhammad A Muquit.
Sending email from the command line is a simple (albeit a tad long winded) command, all on one line of course:
mailsend -from firstname.lastname@example.org -to email@example.com +cc +bc -d gmail.com -smtp smtp.gmail.com -v -starttls -auth-plain -user firstname.lastname@example.org -pass "yourpassword" -sub "Test Subject" -M "This is the body of a test message"