Created
November 1, 2010 18:36
-
-
Save batok/658657 to your computer and use it in GitHub Desktop.
turbomail_gooble.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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