python - IMAP error when accessing gmail from command line -


i working on writing simple script read unread mail gmail through python script. have following script, when run python script, imap error marked below. assistance in issue appreciated.

i have imap enabled in gmail settings. there other configuration need take care of, working?

import imaplib obj = imaplib.imap4_ssl('imap.gmail.com','993') obj.login('username','password') obj.select() obj.search(none,'unseen') 

where, username gmail username, , password password gmail account.

traceback (most recent call last):   file "test.py", line 3, in <module>     obj.login('ashwin.tumma23@gmail.com',password)   file "/usr/lib/python2.7/imaplib.py", line 519, in login     raise self.error(dat[-1]) imaplib.error: [alert] please log in via web browser:     https://support.google.com/mail/accounts/answer/78754 (failure) 

visibleman's answer correct. alternative though may wish switch script using gmail api instead of imap. gmail api uses oauth 2.0 authentication more secure. gmail api easier protocol work imap.


Comments

Popular posts from this blog

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -