Skip to content

Instantly share code, notes, and snippets.

@batok
Created November 1, 2010 18:36
Show Gist options
  • Save batok/658657 to your computer and use it in GitHub Desktop.
Save batok/658657 to your computer and use it in GitHub Desktop.
turbomail_gooble.py
def email(to, subject, body, filenames = []):
try:
usuario, password = get_google_account()
source = usuario
if "@" in usuario:
#if usuario.split("@")[-1] == "gmail.com":
#usuario = usuario.split("@")[:-1]
pass
else:
return False
email_config = { "mail.on": True, "mail.transport" : "smtp", "mail.smtp.server": "smtp.gmail.com:587", "mail.smtp.username": usuario, "mail.smtp.password": password, "mail.smtp.tls": True}
turbomail.interface.start( email_config )
message = turbomail.Message(source, to, subject)
message.plain = body
for filename in filenames:
fname = filename.split(os.path.sep)[-1]
with open(filename, "rb") as f:
message.attach(f, fname)
message.send()
turbomail.interface.stop()
except:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment