Follow this steps carefully to integrate IMAP/SMTP of Microsoft Outlook.
1. Go to the Microsoft Azure Portal and click on Microsoft Entra ID. If it's not available, check on More services.
2. Click on App registrations from left menu the click New registration.
3. After that, you'll get a form like this. Fill up as below. In Redirect URI, you should add this link https://yourdomain.com/index.php/mailbox_microsoft_api/save_outlook_imap_access_token/1. You'll find this in your integration setting. Finally click on Register button.
4. Now, you'll get the Overview page. Copy Client ID from there and add to integration settings.
You can add one more redirect url if you want to use it for SMTP (outgoing email) also. To do that, click on the Redirect URIs.
You'll also get this in integration setting.
5. Click on API permissions from left menu. Then click on Add a permission.
6. Click on Microsoft Graph.
7. Click on Application permissions.
8. Search Mail.ReadWrite, OnPremisesPublishingProfiles, User.Read.All and enable the permissions.
Enable Mail.Send permission to use SMTP.
9. Click on Certificates & secrets from left menu. Then click on New client secret.
10. Fill up the form like below and click on Add button.
11. After that, you'll get the Client secret.
12. Add this Client secret also to the integration settings and click on Save & authorize. The page will be redirected to Microsoft account. Click on the Accept button from the consent page.
13. After redirect, please check the settings are Authorized.