IMAP authentication fails for Office365 domain (though SMTP works fine)

Hi everyone,
we’ve been struggling with an issue related to Email Account config. Here’s the scenario:

  1. Email Domain configured with incoming/outcoming servers, ports, SSL and TLS provided by Office 365
  2. Email Account configured with email_id, office365 domain, password, and outgoing emails enabled.
  3. Testing if emails are correctly sent and they are indeed
  4. Back to Email Account doc, enabling incoming emails, trying to save changes and the exception above appears. We are not able to receive emails, and they are still sent although a prompt requesting for right credentials pops up.
imaplib.IMAP4.error: b'LOGIN failed.'

(...)

frappe.email.smtp.InvalidEmailCredentials: Please check your email login credentials.

Has anyone faced this same issue? Am I missing something related with Office365’s inner config maybe?

Office 365 has deprecated Basic Auth for IMap and POP last week. This should be causing a break. I don’t know of any work arounds, unless Advance Auth is implemented by ERPNext

Deprecation of Basic Auth

Yes, that is definitely causing the issue. Thanks for sheding light on this topic @saurabhn

You can temporarly reenable IMAP Basic Auth in the Exchange Admin Center → Help → Type in “Basic Auth” → Run diagnosis → Enable IMAP

1 Like

Won’t this get disabled again in Dec 2022 as per info available? There needs to be some permenant fix!

Yes, it’s working for now but will be permanently removed next January.
SMTP will remain active …

I don’t know if any trick could be used to authenticate in 365 service to keep incoming and outgoing mail working … but it is really needed. :sweat_smile:

There is a related issue opened on Github.