Configure SMTP with OAuth Authentication
OAuth 2.0 lets Nectari authenticate to your SMTP provider without storing an SMTP username and password. This setup requires configuration in Microsoft Entra ID and Exchange Online before you enter the OAuth settings in Nectari.
Configure OAuth 2.0 for Exchange Online (Microsoft 365)
1. Register an app in Microsoft Entra ID
- Sign in to the Microsoft Entra admin center with an account that has at least the Application Developer role.
- If you manage multiple tenants, select Settings and switch to the tenant that hosts your Exchange Online environment.
- Go to Entra ID > App registrations, and then select New registration.
- Enter a name for the app, such as
nectari-smtp-app. - Under Supported account types, select Accounts in this organizational directory only (Single tenant).
- Select Register.
- On the app Overview page, copy the Application (client) ID and the Directory (tenant) ID for later use in Nectari.
For a complete guidance, see Microsoft's guidance to Register an application with Microsoft Entra ID.
2. Add the SMTP permission
- In the app registration, select API permissions.
- Select Add a permission.
- Select APIs my organization uses, search for Office 365 Exchange Online, and then select it.
- Select Application permissions.
- Select SMTP.SendAsApp under SMTP, and then select Add permissions.
Optionnally, you may also want to remove unused permissions granted by default to the app, such as User.Read for Microsoft Graph.
3. Grant tenant admin consent
A tenant administrator must grant admin consent for the permissions assigned to the app. For background, see Permissions and consent. For Exchange Online SMTP, use the scope value https://outlook.office365.com/.default.
Single-tenant app registrations
If you registered the app as Accounts in this organizational directory only (Single tenant), grant consent from the app registration:
- In Microsoft Entra ID, open your app registration.
- Select API permissions.
- Select Grant admin consent for
<tenant>.
Multi-tenant app registrations (partner/ISV)
If the app was registered as Accounts in any organizational directory (Multitenant), the tenant administrator can grant consent by using an admin consent URL:
https://login.microsoftonline.com/{tenant}/v2.0/adminconsent?client_id=<CLIENT_ID>&redirect_uri=<REDIRECT_URI>&scope=https://outlook.office365.com/.default
4. Create a client secret
- In the app registration, select Certificates & secrets.
- Select New client secret.
- Copy the secret value and store it securely because Microsoft shows it only once.
5. Register the service principal in Exchange Online
A tenant administrator must register your Microsoft Entra application's service principal in Exchange Online so the app can authenticate by using the OAuth 2.0 client credentials flow. Run the commands in the order shown and replace values in <REQUIRED_VALUES> with your tenant information.
Required values
| Value | Where to find |
|---|---|
<TENANT_ID> | Directory (tenant) ID from Microsoft Entra ID app registration Overview page. |
<APPLICATION_ID> | Application (client) ID from Microsoft Entra ID app registration Overview page. |
<ENTERPRISE_APP_OBJECT_ID> | Azure Portal > Enterprise applications > your app > Overview (Object ID). |
<SERVICE_PRINCIPAL_ID> | Exchange Online PowerShell output from Get-ServicePrincipal | fl (the ID field). |
Use the Object ID from Enterprise applications, not the one from App registrations.