Skip to content

Instantly share code, notes, and snippets.

@audente
audente / GMail.py
Created April 18, 2013 16:17
Python functions to send mail using GMail. Usage: from GMail import GMailServer, SendMail with GMailServer('username', 'password') as server: SendMail(server, 'fromaddr', 'toaddrs', 'subject', 'body')
# --------------------------------------------------
import smtplib
class GMailServer:
def __init__(self, username, password):
self.server = smtplib.SMTP('smtp.gmail.com:587')
self.server.starttls()
self.server.login(username,password)
def __enter__(self):