[Python] Authenticate with Exchange to access email inbox with imaplib

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have a python script that used to login to an outlook inbox:

    from imaplib import IMAP4_SSL

    imap = IMAP4_SSL("outlook.office365.com")
    imap.login("user", "password")


    It now fails with an error:

    Traceback (most recent call last):
    File "imap.py", line 4, in <module>
    imap.login("user", "password")
    File "/usr/lib/python3.8/imaplib.py", line 603, in login
    raise self.error(dat[-1])
    imaplib.error: b'LOGIN failed.'


    Microsoft has disabled basic authentication for Exchange Online. How should I authenticate now that basic auth has been deprecated?

    Continue reading...

Compartilhe esta Página