A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.
Hello! I'm Mason, i will do my best to help you with this problem.
In my understanding, two Mutually Exclusive Authorization Paths Are Conflicting
Your configuration is mixing two distinct authorization models for SMTP.SendAsApp, and that conflict is most likely causing the persistent 535 5.7.3. Let me explain.
The Two Paths
Microsoft supports two separate and mutually exclusive authorization models for SMTP client credentials flow:
Path 1: Classic Mailbox Permission
- Requires
SMTP.SendAsAppEntra API permission (with admin consent) - Requires Exchange service principal (
New-ServicePrincipal) - Requires
Add-MailboxPermissionwithFullAccessgranted to the service principal
Path 2: App RBAC (New-ManagementRoleAssignment)
- Does not require mailbox permissions
- Does not require
SMTP.SendAsAppas an Entra API permission - Microsoft's own documentation explicitly warns: "Refrain from adding any permissions to your application, as this process does not require any claims. Including the SMTP.SendAsApp claim would trigger an unnecessary check for mailbox permissions."
Your configuration has the SMTP.SendAsApp Entra permission (with admin consent) and the New-ManagementRoleAssignment RBAC path active simultaneously. Exchange sees the SMTP.SendAsApp claim in the token and triggers the mailbox permission check — but your authorization is through RBAC, not through Add-MailboxPermission. The check fails silently and you receive 535 5.7.3.
Resolution: Choose One Path and Remove the Other
Option A — Pure RBAC Path (recommended for your scenario)
- Remove the
SMTP.SendAsAppapplication permission from your Entra app registration entirely. The token must not carry that claim. - Keep your
New-ServicePrincipal,New-ManagementScope, andNew-ManagementRoleAssignmentas-is. - Re-acquire a fresh token and retry SMTP authentication.
Option B — Classic Mailbox Permission Path
- Keep
SMTP.SendAsAppin Entra with admin consent. - Remove the RBAC role assignments (
Remove-ManagementRoleAssignment). - Run:
Add-MailboxPermission -Identity "******@tenant.onmicrosoft.com" `
-User <EXO_ServicePrincipal_Identity> -AccessRights FullAccess
Add-RecipientPermission -Identity "******@tenant.onmicrosoft.com" `
-Trustee <EXO_ServicePrincipal_Identity> -AccessRights SendAs
Additional Item: Verify SMTP AUTH Is Actually Enabled on the Shared Mailbox
The "Authenticated SMTP" toggle is absent from the shared mailbox UI in the Exchange Admin Center (unlike regular user mailboxes). Even though you ran Set-CASMailbox, confirm it actually applied:
Get-CASMailbox -Identity "******@tenant.onmicrosoft.com" `
| Select SmtpClientAuthenticationDisabled
The value must be False. If it returns True or $null, SMTP AUTH is still disabled for that mailbox regardless of the org-level setting.
Additional Item: Verify the Correct ObjectId Was Used for New-ServicePrincipal
A common silent failure is using the wrong ObjectId. The ObjectId passed to New-ServicePrincipal must come from:
Entra ID > Enterprise applications > Your app > Properties > Object ID
Not from the App Registration blade. These are different GUIDs. Verify with:
Get-ServicePrincipal | Where-Object { $_.AppId -eq "<your-client-id>" } `
| Select AppId, ObjectId, DisplayName
Cross-reference the returned ObjectId against what you originally passed to New-ServicePrincipal -ObjectId.
Additional Item: XOAUTH2 String Construction
Rule out encoding issues by confirming the SASL XOAUTH2 string is constructed exactly as: base64("user=" + smtpAddress + "^Aauth=Bearer " + accessToken + "^A^A")
Where ^A is the SOH control character (U+0001), not a literal caret-A text sequence. MailKit's SaslMechanismOAuth2 handles this correctly. If you are constructing the raw AUTH string manually in PowerShell for diagnostic purposes, a malformed encoding will produce 535 5.7.3 even with a valid token and correct permissions.
I hope this helps!