I want to check gmail's mail.
I wrote this code with python.
import imaplib
import email
UserName = "my_gmail"
PassName = "my_gmail_password"
gmail = imaplib.IMAP4_SSL("imap.gmail.com", '993')
gmail.login(UserName, PassName)
gmail.select("")
head, data = gmail.search(None, 'ALL')
but occured this error.
error Traceback (most recent call last) in 8 9 gmail = imaplib.IMAP4_SSL("imap.gmail.com", '993') ---> 10 gmail.login(UserName, PassName) 11 gmail.select("") 12
~/.pyenv/versions/3.7.4/lib/python3.7/imaplib.py in login(self, user, password) 596 typ, dat = self._simple_command('LOGIN', user, self._quote(password)) 597 if typ != 'OK': --> 598 raise self.error(dat[-1]) 599 self.state = 'AUTH' 600 return typ, dat
error: b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)'
Why this error occure? And how do I slove this error? Please tell me.