Posted on November 11, 2010.
While writing random API scripts and other short one off scripts, I usually
need to send an email. Since my scripts usually do not live on a mail server,
I ended up using this piece of code a lot. It uses the smtplib module of
the standard library so it doesn’t have any dependencies outside of standard
python.
It’s a simple python module for sending a text/plain email from a valid gmail
account. After importing, use it like so:
gmail = GMail('username', 'password') gmail.send_email('This is the subject', 'To address')
Find the full module here as a github gist.