Microsoft blocks IMAP Port for basic authentication. im sure the problem will rise again. to avoid this just enable MFA on your office 365 email and create an app password.

microsoft tends to do so to push all people to use the modern authentication method. ive been in your shoes.