A step by step guideline for setting up SMTP Settings for Office365 for OAuth2 Authentication
- Log into Azure Portal and navigate to Azure Active Directory (AAD).
- From the left menu, select App registrations.
- Click > +New registration above the application list.
- Provide Application Name.
- Choose Supported Account Types.
- Click > Register button. You will be automatically redirected to the new application settings page.
- In the Essentials section at the top of the page, copy the following variables:
- Application (Client) ID
- Directory (Tenant) ID
By default, SMTP AUTH is disabled. We need to enable it for an account which will be used to send email through Office365 using OAuth2. 8. Go back to Azure Portal > App Registrations > Your App.
- From the left menu, select Authentication.
9.2 Then select Mobile and desktop applications

9.3 Put a http://localhost or any valid URL as your ** Custom redirect URIs**

9.4 Press Configure button
9.5 Check the appropriate Supported account types the appriate one, e.g., Accounts in this organizational directory only (.... only - Single tenant)
9.6 Choose Yes for "Allow public client flows".

-
Click > Save button to apply the changes.
-
From the left menu, select API Permissions.
- Choose Microsoft Graph in the right panel.
- Select SMTP.Send in the SMTP section.
- Select openid in the openid section.
- Select offline_access in the offline_access section.
- Select User.read in the User section.
- Click > Add permissions button. This will add two permissions to the application (see below).
By default, SMTP AUTH is disabled. We need to enable it for an account which will be used to send email through Office365 using OAuth2.
-
Open the Microsoft 365 admin center and go to Users > Active users.
-
Select the user, and in the flyout that appears, click Mail.
-
In the Email apps section, click Manage email apps.
-
Verify the Authenticated SMTP setting: unchecked = disabled, checked = enabled.
-
When you're finished, click Save changes.













