Repository navigation
Add a Microsoft 365 (OAuth) mail transport - #101
Merged
Merged
Conversation
Send mail through the Microsoft Graph API using the client credentials flow. The mail control panel gets a transport choice and the application (client) ID, tenant ID and client secret. Upgrade 1019 adds the fields to existing sites.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Nick can now send mail through Microsoft 365 using OAuth, as an alternative to SMTP with a user name and password.
mailcontrol panel gets a Mail transport choice (SMTP or Microsoft 365 (OAuth)) and a Microsoft 365 (OAuth) tab with the Application (client) ID, Tenant ID and Client secret. The secret uses the password widget, so it is never returned and an empty value keeps the stored one.https://graph.microsoft.com/.default), caches it in memory until a minute before it expires, and sends the message through the Microsoft GraphsendMailendpoint for the site "From" address.sendMail()is unchanged.pnpm seed:upgrade.docs/admin-guide/mail.mdwith the Azure setup (app registration,Mail.Sendapplication permission with admin consent, client secret, optional application access policy).Only Microsoft 365 is supported. Graph was chosen over SMTP XOAUTH2 because it only needs the
Mail.Sendapplication permission, while XOAUTH2 also needs the app registered in Exchange Online and SMTP AUTH enabled on the mailbox.Commits
pnpm i18n(they are untranslated).Checks
src/helpers/mail/mail.test.tswithfetchmocked: token request and Graph request shape, token reuse, refresh near expiry, authentication and send errors, missing settings, and the SMTP path. Mail and controlpanels tests pass (33), typecheck and lint pass..jsonbefore and afterpnpm i18n: no translation lost.