Mail via Microsoft Graph
Send magic links from an Exchange Online mailbox as an Entra ID app - no SMTP, no mailbox password.
Send sign-in and invite mail from an Exchange Online mailbox through Microsoft
Graph sendMail. Eddytor authenticates as an Entra ID app with the application
permission Mail.Send, restricted to one sender mailbox. Use this instead of
SMTP on Microsoft 365.
Before you start
- A sender mailbox, e.g. a shared mailbox
eddytor@contoso.com. - An identity for Eddytor - not the SSO app:
credential | Where | Setup |
|---|---|---|
managed_identity | Azure VM, VMSS, AKS node | System- or user-assigned managed identity. For user-assigned, set client_id. |
workload_identity | AKS with workload identity | Federated credential with subject system:serviceaccount:<namespace>:eddytor-server. |
client_secret | Anywhere | App registration with a client secret in EDDYTOR_MAIL_CLIENT_SECRET. |
Restrict the identity to the mailbox
In Exchange Online PowerShell (<client-id> = the identity's client ID,
<object-id> = its enterprise application object ID):
New-ServicePrincipal -AppId <client-id> -ObjectId <object-id> -DisplayName "Eddytor Mail"
New-ManagementScope -Name "Eddytor sender" -RecipientRestrictionFilter "PrimarySmtpAddress -eq 'eddytor@contoso.com'"
New-ManagementRoleAssignment -App <client-id> -Role "Application Mail.Send" -CustomResourceScope "Eddytor sender"
Test-ServicePrincipalAuthorization -Identity <client-id> -Resource eddytor@contoso.comHeads up
Mail.Send in the Entra portal as well. An
Entra grant covers every mailbox in the tenant, whatever the Exchange scope
says.Configure
# .env
EDDYTOR__MAIL__PROVIDER=graph
EDDYTOR__MAIL__FROM=eddytor@contoso.com
EDDYTOR__MAIL__TENANT_ID=<tenant-id>
EDDYTOR__MAIL__CLIENT_ID=<client-id>
EDDYTOR__MAIL__CREDENTIAL=client_secret
EDDYTOR_MAIL_CLIENT_SECRET=<client-secret>helm upgrade --install eddytor oci://ghcr.io/nordalf/charts/eddytor -n eddytor --reuse-values \
--set config.mail.provider=graph \
--set config.mail.from=eddytor@contoso.com \
--set config.mail.credential=workload_identity \
--set-string 'server.serviceAccount.annotations.azure\.workload\.identity/client-id=<client-id>' \
--set-string 'server.podLabels.azure\.workload\.identity/use=true'The workload-identity webhook injects the tenant and client ID.
The same keys work under [mail] in config.toml. With provider = "graph",
EDDYTOR_SMTP_* is ignored. Restart the server afterward.
Verify
The server logs mail backend: Graph token acquired at boot. Then sign in with
a magic link.
Gotchas
mail backend: Graph token request failedcarries the Entra error code (AADSTS…): a wrong tenant, client ID, secret, or federated credential.Graph sendMail failed: HTTP 403 ErrorAccessDenied- the identity may not send asfrom. Check the management role assignment above.- Messages are HTML only and are not saved to Sent Items.