Sunday, August 19, 2012

send email through gmail from command line (useful for batch files, windows task manager, remote monitoring)

I wrote send-mail-gmail.stex.py, an open source small and simple python script to send mail through gmail from command line, via smtp.gmail.com, using TLS authentication, on port 587.

Download it from http://code.google.com/p/infoarch-scripts/downloads/list

The python script should work in Windows, Linux, Mac and doesn't need any other program/server, etc.

In the download package you'll find also a batch file to send scheduled mail from the Windows Task Manager (I had problems executing directly from Task Manager the python script with arguments).



Script history :
I tried to use the cygwin "email" program without installing a MTA, with no success, then I searched for a python solution and I found the page http://www.daniweb.com/software-development/python/code/380881/python-3-and-python-2-send-email-through-gmail, that inspired me to write this script.

Other solutions to send mail from command line (not tested) :