Implement Microsoft OAuth2 authentication for SMTP - #1702
Merged
Conversation
…configuration mocks
YoshihitoAso
approved these changes
Dec 17, 2025
purplesmoke05
force-pushed
the
feature/mail-xoauth
branch
from
December 17, 2025 01:28
6992a25 to
0ca1e97
Compare
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
📌 Description
This pull request adds support for Microsoft OAuth2 (XOAUTH2) authentication for SMTP email sending, in addition to the existing password-based and Amazon SES methods. It introduces new configuration options, updates the mail sending logic to handle OAuth2 tokens, and provides unit tests to ensure correct behavior for both authentication methods. Documentation is also updated to reflect the new options and configuration matrix.
4. Unit Testing
Mailclass to verify both password and XOAUTH2 authentication flows, using mocks to ensure correct SMTP interactions and token handling.✅ Related Issues
🔄 Changes
Major additions and changes:
1. Microsoft OAuth2 (XOAUTH2) SMTP Support
SMTP_MS_TENANT_ID,SMTP_MS_CLIENT_ID,SMTP_MS_CLIENT_SECRET,SMTP_MS_REFRESH_TOKEN) and updating the configuration and documentation accordingly. [1] [2] [3] [4]TokenProviderabstraction and aMicrosoftTokenProviderclass to securely retrieve and cache Microsoft access tokens for SMTP authentication.2. Mail Sending Logic Updates
Mailclass inmail.pyto support both password and XOAUTH2 authentication methods, including logic to perform XOAUTH2 authentication with the SMTP server using the access token. [1] [2] [3]3. Configuration and Documentation
ENV_LIST.mdto document all supported SMTP authentication methods, Microsoft OAuth2 settings, and provided a configuration matrix for clarity. [1] [2] [3] [4] [5]📌 Checklist