2

I'm having the following error:

Response status "OK" expected, but "NO" received. Data: [b'LOGIN failed.']

I'm using the library imap-tools. My code is in Python:

from imap_tools import Mailbox, AND

with MailBox('outlook.office365.com').login(login, password) as mailbox:

   data = datetime.today() - timedelta(days=1)
   data_anterior = data.strftime("%d-%b-%Y")

   for msg in mailbox.fetch(AND('SINCE 22-jun-2022')):
      message_ID = (msg.headers['message-id'])
      try:
         for att in msg.attachments: 
            if '.xml' in att.filename:
                get_enconding = chardet.detect(att.payload)
                payload = str(att.payload, get_enconding['encoding']).upper()
                
halfer
  • 19,824
  • 17
  • 99
  • 186
  • What server? What’s your code? Can you log in with a desktop email client like thunderbird? – Max Jul 25 '22 at 18:47
  • outlook.office365.com, my code structure in login is with MailBox('outlook.office365.com').login(login, password) as mailbox: – Murilo Maschke Ferreira Jul 25 '22 at 20:03
  • Please refer to the dozens of recent questions about logging into Microsoft servers with plain authentication. It is generally not allowed unless your admin turns it on, and it will be disallowed completely within a few weeks. – Max Jul 25 '22 at 20:25
  • To further elaborate, you will need to implement full OAuth2, and it seems to me the community is still trying to figure out the best way to do this with microsoft and the seemingly dozens of ways to get OAUTH2 tokens. – Max Jul 25 '22 at 20:27

0 Answers0