Skip to content

Failure logging into Outlook  #602

@DenofTranquility

Description

@DenofTranquility

I've had the same code be working for years but randomly I can't now login to the server.
My credentials are in a separate .env file, I then use python-decouple to import them and login.
I've checked the details multiple times and they are all correct, I use App Passwords from outlook as it doesn't work otherwise.

I used the interactive console to login with the same details and that worked strangely.

I've enabled logging but it hasn't given me any information that I can use.

2024-08-07 17:37:36,759 - DEBUG: < b'PEAA1 NO LOGIN failed.'
2024-08-07 17:37:36,760 - DEBUG: 	matched b'(?P<tag>PEAA\\d+) (?P<type>[A-Z]+) (?P<data>.*)' => (b'PEAA1', b'NO', b'LOGIN failed.')
2024-08-07 17:37:36,760 - DEBUG: NO response: b'LOGIN failed.'
2024-08-07 17:37:36,760 - DEBUG: > b'PEAA2 LOGOUT'
2024-08-07 17:37:36,777 - DEBUG: < b'* BYE Microsoft Exchange Server IMAP4 server signing off.'
2024-08-07 17:37:36,777 - DEBUG: 	matched b'\\* (?P<type>[A-Z-]+)( (?P<data>.*))?' => (b'BYE', b' Microsoft Exchange Server IMAP4 server signing off.', b'Microsoft Exchange Server IMAP4 server signing off.')
2024-08-07 17:37:36,777 - DEBUG: untagged_responses[BYE] 0 += ["b'Microsoft Exchange Server IMAP4 server signing off.'"]
2024-08-07 17:37:36,778 - DEBUG: BYE response: b'Microsoft Exchange Server IMAP4 server signing off.'
2024-08-07 17:37:36,778 - DEBUG: Logged out, connection closed

From the .env file:

IMAP_SERVER_NAME=outlook.office365.com
IMAP_PORT=993
IMAP_ENCRYPTION_METHOD=TLS

From the main.py:

IMAP_server_name = config('IMAP_SERVER_NAME')
IMAP_port = config('IMAP_PORT')
IMAP_encryption_method = config('IMAP_ENCRYPTION_METHOD')

username = config('USERNAME')
password = config('PASSWORD')

    with IMAPClient(IMAP_server_name) as server:
        print(f'[+] Logging in as {username}')
        server.login(username, password)
        print(f'[+] Entering folder {folder}')

Any ideas of what else I could try or have Microsoft nuked the login procedure?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions