问题
I have a simple python program as follows -
import imaplib
mail = imaplib.IMAP4_SSL('mail.o365.mailserver.com')
print mail.login('myuserid@domain.com', 'MyPassword')
print('Logged in')
I receive an error -
File "C:\Python27\lib\imaplib.py", line 520, in login
raise self.error(dat[-1])
error: LOGIN failed.
I found a link - http://bioportal.weizmann.ac.il/course/python/PyMOTW/PyMOTW/docs/imaplib/index.html
However, this link stats that you get this error when the credentials are incorrect. EDIT - Please note that my credentials are correct.
Kindly note that the connection to my mailserver happens correctly and an instance is successfully received.
Can Anyone please comment on the issue.
回答1:
I had the same problem and I got in the Spam folder a Critical Security Alert email from Google. "Someone just used your password to try to sign in to your account. Google blocked them, but you should check what happened."
When you review the activity you can indicate that this was a secure attemp and grant access for it. That solved my issue
来源:https://stackoverflow.com/questions/42672263/python-error-when-connecting-to-outlook-imap-raise-self-errordat-1-error