RotherOSS / MailAccount-OAuth2

Enables receiving emails (IMAP and POP3) via OAuth 2.0 authorization (RFC 6749).
0 stars 4 forks source link

Hotfix: Microsoft Exchange Online Auth for TLS #6

Closed eyazi closed 1 year ago

eyazi commented 1 year ago

Currently, multiple systems are facing problems pulling their mail via IMAPTLS from Microsoft Exchange Online.

This PR creates a socket beforehand and passes the socket to the IMAP client.

This does not seem to be an issue for POP3.

svenoe commented 1 year ago

Hi Emin, thanks for the hotfix! We currently thought this might be connected to https://support.nhs.net/2023/06/microsoft-365-alert-service-degradation-microsoft-365-suite-some-users-may-experience-intermittent-performance-issues-with-various-microsoft-365-services/

Do you think opening the socket in advance is good practice in general, and do you think other systems can be negatively affected by the change?

eyazi commented 1 year ago

Hello Sven,

I honestly don't know how Mail::IMAPClient is establishing the connection. There are two parameters, Ssl => 1 and Port => 993, which both don't resolve the problem.

Creating another socket was the only way for me to resolve the issue. I made tests on multiple test and productive systems and I haven't faced any issues. I'd guess that > 95% of the users use this add-on for Microsoft 365, but I agree that some more tests should be made on different environments.

This might at least be a fast fix for people in need.

eyazi commented 1 year ago

Okay, looks like the underlying problem is something else.

IMAPOAuth2.pm is by default using Starttls, which is and was never supported with Microsoft Exchange Online. And it seems like Microsoft stopped that support on the weekend for some Tenants.

Starttls => [ SSL_verify_mode => 0 ],

Should be replaced by

Ssl => 1,

Ssl makes sure that Port 993 is getting used.

svenoe commented 1 year ago

Thanks for the updates! We will have a look at this tomorrow and likely release a new version then.