How to send an email through gmail using python? -


i'm trying send emails gmail account using python. i've read many questions here , around internet, none of them solved problem.

the code i'm using following (thanks rosettacode), similar many other code snippets can found topic:

def sendemail(from_addr, to_addr_list, cc_addr_list,               subject, message,               login, password,               smtpserver='smtp.gmail.com:587'):     header  = 'from: %s\n' % from_addr     header += 'to: %s\n' % ','.join(to_addr_list)     header += 'cc: %s\n' % ','.join(cc_addr_list)     header += 'subject: %s\n\n' % subject     message = header + message      server = smtplib.smtp(smtpserver)     server.ehlo()     server.starttls()     server.ehlo()     server.login(login,password)     problems = server.sendmail(from_addr, to_addr_list, message)     server.quit()     return problems 

my problem during login phase. returns following error message:

smtpauthenticationerror: (534, '5.7.14 <https://accounts.google.com/continuesignin?sarp=1&scc=1&plt=akgnsbsmx\n5.7.14 z4_8qlgwtbhs2cwfvvapfvrfpis1vbbfun6ghcf0d6jgsq-ixmn79mf3aivvets9ihysgq\n5.7.14 pmrp157h4vmk6-ybac9u2d2lnmyyy5pdmociqesxbbwfgepgjkhkdjpsocx86gzg-im6v-\n5.7.14 hsoemkijraugzjhuprewj8oabwlzwq8vezovpxk79m-i8cnfsew-pnlxllsk21walhlkmz\n5.7.14 ll3tegq> please log in via web browser , try again.\n5.7.14 learn more at\n5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 dc8sm25406976wib.7 - gsmtp') 

i followed suggested link , found this answer, don't know if solution.

so, what's problem? account's settings? code?

google has tightened security. application use username/password directly have been deactivated. users still able reactivate these less secure application in security settings have been reading in link gave in question. solution @ point.

the alternative use other smtp server sending.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -