Python error when connecting to Outlook IMAP - raise self.error(dat[-1]) error: LOGIN failed

拟墨画扇 提交于 2021-02-08 11:41:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!