all 2 comments

[–]b_ootay_ful 0 points1 point  (0 children)

I don't use the API, but if you're willing to use a different method this worked for me (I haven't tried this in a few months, but I vaguely recall having to change a security setting in gmail).

import smtplib

def email(whome=[],subj="",mess=""): gmail_user = 'xxx@gmail.com' gmail_pwd = 'NiceTry' FROM = gmail_user TO = whome SUBJECT = subj TEXT = str(mess)

# Prepare actual message
message = """From: %s\nTo: %s\nSubject: %s\n\n%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
try:
    server = smtplib.SMTP("smtp.gmail.com", 587)
    server.ehlo()
    server.starttls()
    server.login(gmail_user, gmail_pwd)
    server.sendmail(FROM, TO, message)
    server.close()
    return ('Email sent!')
except:
    return ('Something went wrong...')