def send_email_gmail(username, password, email_to, email_from, subject, body, debug=False):
    # connect to remote mail server and forward message on 
    server = smtplib.SMTP("smtp.gmail.com", 587)
    message = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % (email_from, email_to, subject, body)

    smtp_sendmail_return = ""
    if debug:
        server.set_debuglevel(True)
    try:
        server.ehlo()
        server.starttls()
        server.login(username,password)
        smtp_sendmail_return = server.sendmail(email_from, email_to, message)
    except Exception, e:
        exception = 'SMTP Exception:\n' + str( e) + '\n' + str( smtp_sendmail_return)
    finally:
        server.quit()
dataset/ETHPy150Open tatanus/SPF/spf/core/emails.py/send_email_gmail/original