Fix Microsoft 365 IMAP and SMTP Connection Errors with OAuth
Question details
Users need to correctly configure Microsoft 365 IMAP/SMTP server settings and update their custom applications to use OAuth 2.0 since Basic Authentication is no longer supported.

- Product
- Microsoft 365
- Device & OS
- not provided
- Scenario
- A custom VB.NET application fails to send or receive emails via IMAP/SMTP after migrating to Microsoft 365.
- Observed behavior
- The application fails to connect using basic authentication, even though standard clients like Outlook work perfectly fine.
Ensure you have access to the Microsoft Entra ID (formerly Azure AD) admin center with sufficient privileges to register new applications and grant API permissions.
Configure Server Settings and Implement OAuth 2.0 in Microsoft Entra ID
Use this method to securely connect your application to Microsoft 365 using modern authentication (OAuth 2.0) instead of the deprecated Basic Authentication.
Exchange Online has permanently disabled Basic Authentication for IMAP and SMTP protocols. To restore email functionality, custom applications must be registered in Microsoft Entra ID and configured to request OAuth 2.0 access tokens instead of relying on a plain username and password.
Configure your application to use the IMAP server 'outlook.office365.com' on port 993 with SSL enabled, and the SMTP server 'smtp.office365.com' on port 587 with STARTTLS.
Log into the Microsoft Entra ID admin center, navigate to 'App registrations', and create a new registration for your application.
Under 'API permissions', add the delegated permissions 'IMAP.AccessAsUser.All' and 'SMTP.Send' for Microsoft Graph or Office 365 Exchange Online.
Use the Microsoft Authentication Library (MSAL) in your application code to acquire OAuth 2.0 tokens and pass them in the authentication string of your IMAP/SMTP connection requests.

Looking for a Lightweight Alternative to Microsoft Office?
While troubleshooting Exchange server settings and custom application integrations, you might be seeking a more streamlined, cost-effective office suite for your daily document tasks. WPS Office is a powerful, free alternative that provides seamless compatibility with Word, Excel, and PowerPoint files without the heavy overhead.
- 1. Download the Installer: Visit the official WPS website and click 'Download WPS Office Free'.
- 2. Install the Software: Run the downloaded executable file and follow the on-screen instructions.
- 3. Open and Use: Launch WPS Office and instantly open your existing Microsoft Word, Excel, and PowerPoint files.

Frequently Asked Questions
What are the correct Microsoft 365 IMAP and SMTP settings?
For IMAP, use 'outlook.office365.com' with port 993 and SSL enabled. For SMTP, use 'smtp.office365.com' with port 587 and STARTTLS enabled.
Why did my custom application stop sending emails after moving to Microsoft 365?
Microsoft has deprecated Basic Authentication for IMAP and SMTP in Exchange Online. If your application only uses a standard username and password to authenticate, the connection will be blocked until you implement OAuth 2.0.
Do I need admin rights to set up OAuth 2.0 for my app?
Yes, you need sufficient administrative permissions in your organization's Microsoft Entra ID (Azure AD) to register new applications, create client credentials, and grant the necessary API permissions for email access.
Can I bypass OAuth and re-enable Basic Authentication in Microsoft 365?
No, Microsoft has permanently disabled Basic Authentication for these protocols across all tenants to improve security. Upgrading to modern authentication is strictly required.




