Segura® Platform authenticates Microsoft-hosted SMTP and IMAP mail accounts with OAuth2.0 through a native Authenticate flow. This flow replaces the email-oauth2-proxy component for Microsoft accounts and works in multi-tenant environments.
Segura® supports two OAuth2 flows for Microsoft accounts. You choose the flow with the Microsoft OAuth2 flow field on the SMTP account. For a field-level reference, see SMTP configuration.
- Delegated (user consent): the default. A user signs in interactively and grants consent; Segura® sends emails on behalf of that user's mailbox.
- Application (admin consent, app-only): a tenant administrator grants consent once, with no user sign-in at send time. Use it in tenants that require administrator approval for new applications, where the Delegated flow cannot complete because the approval is asynchronous.
This document covers the Azure setup, the credential, and the SMTP account. The Azure application and credential you create here also authenticate IMAP. To configure the IMAP account itself, see Manage IMAP/POP3 settings.
The native flow applies to Microsoft-hosted mail accounts only, identified by host: office365.com, outlook.com, outlook.office365.com, smtp.office365.com, smtp-mail.outlook.com, imap-mail.outlook.com, pop-mail.outlook.com, live.com, hotmail.com, and onmicrosoft.com. For any other provider, use the email-oauth2-proxy method: see Register the email-oauth2-proxy component.
Requirements
- Administrative access to the Microsoft Azure Portal, including rights to grant the requested permissions.
- Administrative access to Segura® Platform.
- The Segura® Platform URL, to register as the Azure redirect URI.
- If you use the Application (app-only) flow, a Microsoft Entra ID administrator must grant admin consent for the application.
Register an application in Azure
The Azure setup steps in this section take place in Microsoft Azure. Microsoft can change this interface and process without notice. If the screens differ from what is described here, consult Microsoft's documentation.
- Access the Azure Portal and log in to your Azure account.
- Locate the service Microsoft Entra ID.
- In the left menu, select Manage > App registrations.
- Select your existing mail application, or select New registration to create one.
- In the application's left menu, select Manage > Authentication.
- Under Web > Redirect URIs, add or update the URI so that it ends with
flow/mail/auth/return. Use the following format, and match it exactly, including the scheme:
https://<your-segura-url>/flow/mail/auth/return
- From the application's Overview page, copy the Application (client) ID and the Directory (tenant) ID. You need both values later.
Generate a client secret
- In the application's left menu, select Manage > Certificates & secrets.
- Select New client secret.
- In the Description field, enter a description for the client secret.
- In the Expires field, select when the client secret expires.
- Select Add.
Copy the Value field of the client secret immediately. Azure hides this value after you leave the page, and you cannot retrieve it later.
Configure API permissions
The Microsoft Graph permissions to add depend on the OAuth2 flow you will use on the SMTP account.
Delegated flow (default)
- In the application's left menu, select Manage > API permissions.
- Select Add a permission, then select Microsoft Graph.
- Select Delegated permissions.
- Add the following permissions:
- Mail.Send: supports sending through SMTP.
- Mail.Read, labeled Read user mail: supports reading through IMAP.
- Select Add permissions.
Azure lists several read permissions with similar names. Select the one labeled Read user mail. A user grants consent to these permissions during the Authenticate step, when they log in to Microsoft.
Application flow (app-only)
- In the application's left menu, select Manage > API permissions.
- Select Add a permission, then select Microsoft Graph.
- Select Application permissions.
- Add the permission Mail.Send, labeled Send mail as any user.
- Select Add permissions.
A tenant administrator grants consent for this permission during authentication, by approving the request in the Azure Portal. For those steps, see Authenticate with Microsoft.
Security recommendation (least privilege): with the application Mail.Send permission, the application can send as any mailbox in the tenant. Restrict the application to the configured sender mailbox with an Application Access Policy in Exchange Online.
Create a credential in PAM Core
- On Segura®, in the navigation bar, hover over the Products menu and select PAM Core.
- Go to Credentials > All credentials, and select Add.
- On the Information tab, complete the following fields:
- Username: enter the Application (client) ID you copied earlier.
- Device: enter the mail provider's host, for example
outlook.office365.comfor a Microsoft 365 account, oroutlook.live.comfor a personal Microsoft account. - Password type: select Local user.
- Additional information: enter the Directory (tenant) ID you copied earlier.
- Password: enter the client secret value you copied earlier.
- Select Save.
If the mailbox is a personal Microsoft account, Segura® Platform always uses the tenant value common, regardless of the Directory (tenant) ID stored in this credential.
Configure the SMTP account
- On Segura®, in the navigation bar, hover over the Products menu and select Settings.
- On the side menu, select Email > SMTP configuration. For the general account fields not covered here, such as account name, sender email, and reply email, see Manage SMTP settings.
- Add a new account, or edit an existing one, for the Microsoft mailbox.
- Complete the following fields:
- Host SMTP: enter the provider's host, for example
smtp.office365.com. - Port: enter
587. - Use safe connection?: select No.
- Ignore certificate error: select Yes.
- Enable footnote: select No.
- Host SMTP: enter the provider's host, for example
- In the Use authentication? field, select Yes.
- In the Credential for authentication field, select the credential you created in Create a credential in PAM Core.
- In the Microsoft OAuth2 flow field, select Delegated (user consent) or Application (admin consent, app-only), to match the permissions you configured in Azure. The default is Delegated.
- Select Send.
Authenticate with Microsoft
After you save the SMTP account, authenticate it with Microsoft. The steps depend on the OAuth2 flow you selected.
Delegated flow
- In the accounts list, select the Actions button for the account, then select Authenticate.
- Segura® Platform displays a message: it will redirect you to Microsoft for authentication, and you will need to log in to Segura® Platform again afterward. Select Yes to continue.
- On the Microsoft screen, select the sender account to authenticate.
- On the Permissions requested screen, review the access and select Accept.
- Segura® Platform displays Success - Authenticated successfully.
- Select Back to login, then log in to Segura® Platform again.
Application (app-only) flow
Use these steps when the account uses the Application flow, where a tenant administrator must approve the request before authentication completes.
- In the accounts list, select the Actions button for the account, then select Authenticate.
- In the redirect confirmation, select Yes.
- On the Microsoft screen, select the sender account to authenticate.
- On the Approval required screen, enter a justification and select Request approval. Microsoft confirms with Request sent. Select Return to the application.
- Segura® Platform displays Consent not completed. This is expected: a tenant administrator must approve the request. Select Back to login.
- Ask a Microsoft Entra ID administrator to approve the request in the Azure Portal:
- Go to Enterprise applications > Admin consent requests and select the pending request.
- Select Review permissions and consent, then sign in with the administrator account.
- Confirm Consent on behalf of your organization, then select Accept.
- Return to Segura® Platform and repeat the Authenticate action. Because consent was granted, Microsoft redirects you back automatically, and Segura® Platform displays Consent completed.
- Select Back to login, then log in to Segura® Platform again.
Test the configuration
- In the accounts list, select the Actions button for the authenticated account, then select Test setting.
- On the Test Email - Account form, enter a destination address in Send to, then select Send.
- When Segura® Platform displays Test email successfully sent, select Continue.
- To audit the send, go to Settings > Email > Outbox and confirm the record status is Sent.
- Check the recipient inbox to confirm the test message arrived.
If a test send fails, check the message Sending via Microsoft Graph failed. Check whether the application permission was approved by the administrator (it may take a few moments to propagate). Confirm that administrator consent was granted and retry.