guideonce.
← All guides

Jira Service Management · Security

Scoping Email This Issue's Graph Access to Two Mailboxes

The default permission lets one app secret read and send as anyone in the tenant. How to narrow it with RBAC for Applications, and the step that makes the scoping do nothing if you skip it.

Where this fits

The migration runbook lists the Graph permissions Email This Issue needs and flags that scoping them is a separate job (infrastructure prerequisites). This is that job.

Email This Issue Cloud can read and send mail through Microsoft Graph with application permissions. Granted the usual way, those permissions are not limited to the mailboxes you care about. This is how to limit them to two shared mailboxes using Exchange Online's RBAC for Applications, in the order that works, and the one step people miss that makes the scoping do nothing.

An honest scope note first. This post is built from Microsoft's and Appfire's published documentation, which I checked against the pages as I wrote. The one first-hand observation in it is the ErrorSendAsDenied error in the delegated section. I have not walked every command below through to the end in my own tenant, and I say where that matters.

The Default Is Every Mailbox in the Tenant

Microsoft's table of Exchange application roles describes Application Mail.Send as allowing the app “to send mail as any user without a signed-in user.” An application permission, consented by an administrator in Entra ID, is tenant-wide unless something narrows it. For Email This Issue, whose client-credentials setup needs Mail.ReadWrite to fetch and Mail.Send to send, that means a client secret for one app can read and send as any mailbox in the organisation.

The two mailboxes it needs are a helpdesk and one other shared mailbox. Everything else is exposure for no benefit.

Which Scoping Method to Use

There are two, and both are PowerShell only. Neither has an admin-centre screen that I know of.

The practical difference that matters: an Application Access Policy only constrains the permissions granted in Entra ID. RBAC for Applications is a separate Exchange-side grant that sits alongside the Entra one. That distinction is the source of the trap in step 4 below.

The App Registration

These are the steps on the Entra and Email This Issue sides. The redirect URI is specific to your Email This Issue instance, so copy it from the app rather than from anywhere else.

  1. In Email This Issue Cloud, go to Administration → OAuth2 Credentials → Add and copy the Redirect URI. Leave that tab open.
  2. In the Entra admin centre, App registrations → New registration. Give it a name that says what it is for, choose single tenant, platform Web, and paste the redirect URI. Single tenant also keeps Conditional Access for workload identities possible later.
  3. Copy the Application (client) ID and the Directory (tenant) ID from Overview.
  4. Certificates & secrets → New client secret. Choose an expiry, add it, and copy the Value immediately, because it is shown once.
  5. From Overview → Endpoints, copy the v2 OAuth 2.0 token endpoint. Appfire's documentation is explicit about taking the v2 endpoint.
  6. API permissions → Add a permission → Microsoft Graph → Application permissions: Mail.ReadWrite and Mail.Send. Then Grant admin consent. It is mandatory for application Mail.Send.
  7. In Email This Issue: provider Microsoft O365, grant type Client Credentials, the client ID, the secret value and the v2 token endpoint. There is no authorisation endpoint, and you do not click Authorize.
A documentation conflict I could not settle

Appfire's Client Credentials page lists User.Read.All as required. A December 2025 Cloud release note says User.Read is “no longer necessary” for client-credentials connections. Those are different permissions and the two statements do not obviously contradict each other, but they leave it unclear whether User.Read.All is still needed. It grants directory-wide read, so I would test without it and add it only if mail does not flow.

Scoping It to the Two Mailboxes

The sequence is: build a group of the allowed mailboxes, create the Exchange-side objects, test, and only then remove the tenant-wide Entra grant. Order matters in the last step.

1. Create the scope group

In the Exchange admin centre, Recipients → Groups → Add a group → Mail-enabled security. Name it something obvious, such as ETI-Scope-Mailboxes. Add the two shared mailboxes as direct members. Microsoft states that nested group members are out of scope, and only direct membership counts. Microsoft 365 Groups, mail-enabled security groups and distribution lists are supported as the group type. Restrict who can join it, because from now on membership of this group is a security control.

2. Get the right IDs

Go to Entra → Enterprise applications, not App registrations, and open the app. Copy the Application ID and the Object ID from there. Microsoft's warning is blunt: do not use the IDs from the App Registrations page, because it shows different values for the same app.

3. Create the Exchange-side objects

This is the part with no admin-centre equivalent. It needs Exchange Organization Management rights, or the Exchange Administrator role in Entra, and the ExchangeOnlineManagement module.

Connect-ExchangeOnline

New-ServicePrincipal -AppId <ApplicationId> -ObjectId <EnterpriseAppObjectId> -DisplayName "ETI Cloud mail"

$dn = (Get-Group "ETI-Scope-Mailboxes").DistinguishedName
New-ManagementScope -Name "ETI Cloud mailboxes" -RecipientRestrictionFilter "MemberOfGroup -eq '$dn'"

New-ManagementRoleAssignment -App <EnterpriseAppObjectId> -Role "Application Mail.Send" -CustomResourceScope "ETI Cloud mailboxes"
New-ManagementRoleAssignment -App <EnterpriseAppObjectId> -Role "Application Mail.ReadWrite" -CustomResourceScope "ETI Cloud mailboxes"

# InScope should be True for a scoped mailbox and False for any other
Test-ServicePrincipalAuthorization -Identity <EnterpriseAppObjectId> -Resource helpdesk@example.com
Test-ServicePrincipalAuthorization -Identity <EnterpriseAppObjectId> -Resource someone.else@example.com

The cmdlet sequence follows Microsoft's published procedure. Microsoft's own worked example uses a different role, Application Calendars.Read, so the Application Mail.Send and Application Mail.ReadWrite role names here come from its roles table, not from an example for mail. Alternatives for the scope are a single-mailbox filter on ExternalDirectoryObjectId, or Administrative Units.

Test-ServicePrincipalAuthorization bypasses the permission cache. The app does not. Microsoft says changes are subject to cache maintenance that “varies between 30 minutes and 2 hours,” so a passing test followed by a failing send is expected for a while.

4. Remove the tenant-wide grant

This is the step that makes it real, and the one that is easy to miss. Microsoft: the assigned permissions are “a union operation on the permissions from Microsoft Entra ID and the permissions assigned in Exchange Online RBAC.” An unscoped Entra grant plus a scoped Exchange grant adds up to no scoping at all. Microsoft makes this point in its own example, with Mail.Read.

In Entra, open the app's API permissions. For Application Mail.Send and Mail.ReadWrite, use the “…” menu to revoke admin consent, then remove the rows. Removing a row alone does not revoke an existing grant, which can persist under “Other permissions granted.” One caution reported by a third-party reviewer: the “revoke all admin consents” button revokes every grant in that group, not just the two.

5. Prove it

Send a test notification from each project and confirm fetch still works. I could not confirm whether Email This Issue's connection test checks the token's role claims, so judge by real mail flow, not by the green tick. Then run Test-ServicePrincipalAuthorization against an out-of-scope mailbox and confirm it says InScope is false.

If You Already Have an Access Policy

For a tenant that already uses one, the equivalent is:

New-ApplicationAccessPolicy -AppId <ApplicationId> -PolicyScopeGroupId eti-scope@example.com -AccessRight RestrictAccess -Description "Restrict ETI Cloud to the two mailboxes"
Test-ApplicationAccessPolicy -Identity helpdesk@example.com -AppId <ApplicationId>        # expect Granted
Test-ApplicationAccessPolicy -Identity someone.else@example.com -AppId <ApplicationId>   # expect Denied

It constrains the Entra grant rather than replacing it, and it is reported to honour nested groups, which RBAC does not. Changes can reportedly take over an hour to apply to Graph REST calls even when the test cmdlet already says Granted. Moving from one method to the other is described as interruption-free if you do it in order: scope, service principal, role assignments, remove the Entra consent, then remove the policy. A DenyAccess policy has no RBAC equivalent.

ErrorSendAsDenied, and the Delegated Alternative

This is the first-hand part. On a delegated connection, sending failed with ErrorSendAsDenied when the signed-in identity and the From address did not line up. In my case the synced UPN of the mailbox was different from its primary SMTP address.

What I can document is what Graph checks. With a delegated token, Exchange compares the From address against the signed-in principal's mailbox rights. Sending as yourself is always allowed. Sending as another recipient needs Mail.Send.Shared and an Exchange Send As or Send on Behalf right on that recipient. Without the Exchange right, Microsoft documents ErrorSendAsDenied.

What I cannot document is exactly why a UPN mismatch triggers it. Email This Issue derives identity from the userPrincipalName. Microsoft documents the check as mailbox permissions, not string equality, so a From address that is a proxy address of the authenticated mailbox should count as “self.” My interpretation is therefore that the authorising identity did not resolve to the same mailbox object as the From address: a different account completed the sign-in, or the UPN belongs to a separate object, or the From address is not in the mailbox's proxy addresses. That is my reading of documented behaviour, not something I proved. The check I would make is to compare the mailbox's email addresses in the Exchange admin centre against the account that authorised the connection.

The ways out, in the order I would choose them:

  1. Move to application access with the scoping above. There is no user identity to match, so the whole problem class goes away.
  2. Grant Send As explicitly, if you are staying delegated. On the shared mailbox, add the authorising account under Send as, and add it under Full Access too if the app sends through /users/{mailbox}. Then make sure Mail.Send.Shared is consented and re-authorise the connection. Microsoft says permission changes can take up to 60 minutes to apply.
  3. Align the identifiers at the source. For a synced account, primary SMTP and UPN are changed on-premises and synced. Both affect customers or sign-in, so this is a change-managed identity task, not a quick fix.
  4. Match the From address to the UPN. It only works if that address is a proxy on the mailbox, and customers then see a different sender. I would not.

Neither scoping mechanism covers delegated access. It is bounded by the signed-in account's own mailbox rights, so least privilege there means a dedicated account with rights on the two shared mailboxes and nothing else. I prefer application access, because no refresh token is tied to a person.

Secrets, and What Expiry Looks Like

Entra client secrets have a maximum lifetime of 24 months, with 6 months offered first. Microsoft recommends under 12 months, and prefers certificates for production. I found no evidence that Email This Issue Cloud accepts certificates, so a secret is what you have. Secrets cannot be extended, only replaced, and the rotation order that does not interrupt mail is:

  1. Create the new secret.
  2. Paste it into the Email This Issue OAuth2 credential and save.
  3. Confirm mail flows.
  4. Delete the old secret.

Put reminders in the diary at 30 and 7 days before expiry, or schedule a Graph PowerShell check of passwordCredentials.endDateTime. When one does expire, token requests fail with AADSTS7000222 (“The provided client secret keys are expired”), reported in payloads as invalid_client. In Email This Issue, expect a red incoming connection with the error in its Protocol Log, outgoing mail in the Error Queue, and a webhook alert if you configured one. Of those, the webhook is the only push signal.

Other Controls, and What I Have Not Verified

What I have not verified

The User.Read.All requirement is unresolved (above). I have not confirmed that Email This Issue's connection test reads role claims. Whether a retirement date for Application Access Policies has since been announced is something to check on the day. The Application Mail.Send and Application Mail.ReadWrite assignments follow Microsoft's role table and procedure, not a mail-specific worked example. And the ErrorSendAsDenied explanation is an interpretation.

Closing Thoughts

The default is too wide and the fix is five steps, but the one to remember is step 4: the first three do nothing until the unscoped Entra grant is removed. Test the out-of-scope mailbox, not just the in-scope one, because a scoping that has not been proved to block anything is not a control.


← All guides