Skip to content

EPIC: FOUR-32115 Microsoft Graph Integration - #8906

Open
sanjacornelius wants to merge 12 commits into
developfrom
epic/FOUR-32115
Open

EPIC: FOUR-32115 Microsoft Graph Integration#8906
sanjacornelius wants to merge 12 commits into
developfrom
epic/FOUR-32115

Conversation

@sanjacornelius

@sanjacornelius sanjacornelius commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

This PR adds Microsoft Graph support to the Send Email connector, allowing users to send emails through Microsoft 365 using the Microsoft Graph API.

The integration uses the OAuth2 client credentials flow to authenticate with Azure and send emails without relying on traditional SMTP authentication. It also includes support for connection validation, token management, and sending file attachments through Microsoft Graph.

ci:connector-send-email:epic/FOUR-32115

Solution

  • Added Microsoft Graph as a supported Send Email provider.
  • Implemented OAuth2 client credentials authentication.
  • Added connection validation for Azure credentials.
  • Added support for sending emails through the Microsoft Graph API.
  • Added support for file attachments.
  • Improved error handling for authentication and send failures.
  • Added unit test coverage for authentication, token retrieval, and email sending.

How to Test

  1. Create a new Send Email connector using Microsoft Graph as the provider (driver).
  2. Configure the Azure Tenant ID, Client ID, Client Secret, and sender email address.
  3. Test the connection and verify it succeeds.
  4. Create a process with a Send Email connector.
  5. Configure the connector to use the Microsoft Graph email server.
  6. Run the process.
  7. Verify the email is delivered successfully.
  8. Configure the connector to include one or more file attachments.
  9. Run the process again and verify the email is received with the expected attachments.
  10. Verify invalid Azure credentials return an appropriate error message.
  11. Run the unit tests and confirm they all pass.

Related Tickets & Packages

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

Introduce MicrosoftGraphTokenProvider to obtain and cache OAuth2 client-credentials tokens from Microsoft Graph. The provider validates required credentials, posts to the tenant token endpoint via Guzzle, throws a RuntimeException on missing creds or HTTP errors (propagating server error messages), and caches the access token for ~50 minutes using a server-specific cache key. Includes unit tests that assert exception behavior for missing credentials and mock Guzzle to verify token request parameters and caching behavior.
Add an optional Guzzle Client dependency to MicrosoftGraphTokenProvider so an HTTP client can be injected for testing. The constructor now accepts ?Client $httpClient and the provider uses $this->httpClient ?? new Client() when posting for tokens. Update the unit test to mock GuzzleHttp\Client (remove overload-based mock and separate-process annotations), import Client, and pass the mocked client into the provider. This enables dependency injection and simpler, more reliable tests.
Replace Mockery-based response mocks in MicrosoftGraphTokenProviderTest with an actual GuzzleHttp\Psr7\Response instance. Simplifies the test by providing a real PSR-7 response (200) with a JSON body and removes the need to mock getBody()/getContents() and getStatusCode(). Added the Response use statement.
Add Microsoft Graph token provider with client credentials flow and unit tests
Introduce Microsoft Graph mail support: add MicrosoftGraphTransport and MicrosoftGraphMessageConverter to send emails via the Graph API and a MicrosoftGraphTokenProvider to obtain access tokens. Integrate the transport into OauthMailManager (createTransport/createMicrosoftGraphTransport) and register a 'microsoft_graph' mailer in config/mail.php. Update the admin settings UI to show the authorization button when the mail driver is set to 'microsoft_graph'. The transport posts a sendMail payload to the Graph endpoint and throws a TransportException on HTTP errors.
@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-35f64bfa59.engk8s.processmaker.net

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-35f64bfa59.engk8s.processmaker.net

Drop the use of Illuminate\Support\Facades\Cache and the Cache::remember call so getAccessToken always calls requestAccessToken.
Add convertAttachments() to MicrosoftGraphMessageConverter to map Symfony Email attachments to Microsoft Graph fileAttachment objects (name, contentType, contentBytes base64) and include them in toSendMailPayload when present.
Remove Microsoft Graph Configuration Caching
@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-35f64bfa59.engk8s.processmaker.net

Include File Attachments in Microsoft Graph Emails
@processmaker-sonarqube

Copy link
Copy Markdown

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-35f64bfa59.engk8s.processmaker.net

@sanjacornelius sanjacornelius changed the title [WIP] EPIC: FOUR-32115 Microsoft Graph Integration EPIC: FOUR-32115 Microsoft Graph Integration Jul 31, 2026
@eiresendez
eiresendez self-requested a review August 1, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants