[Tutor] IMAP Login Error - raise self.error(dat[-1])

Sreekul Nair nair.sreekul at gmail.com
Thu Mar 9 01:05:10 EST 2017

Dear All,

I have tried to search for related issues in StackOverflow and other python
forums but to no avail. And I am really growing desperate to resolve this
issue. I am not sure who would be able to help me if not you guys. Its an
earnest request to please help me understand what I am doing wrong.

Below is the Python code that I have written to simply log into my Outlook
365 server.

import imaplib
mail = imaplib.IMAP4_SSL('mail.o365.mailserver.com')
print mail.login('myuserid at domain.com', 'MyPassword')
print('Logged in')

Running this simple program ends in following error -
File "C:\Python27\lib\imaplib.py", line 520, in login
raise self.error(dat[-1]) error: LOGIN failed.

I have used Python 2.7.12 & 3.6 but to no avail.

Request help on this issue.

Thanks & regards,
Sreekul Nair

More information about the Tutor mailing list