Hi Anagh,
I think you can achieve this without completely redesigning your existing email functionality. However, the approach depends on whether you want Mendix itself to handle OAuth authentication or delegate that responsibility to an SMTP relay.
Since you are using Mendix 9.18.2 with Microsoft Entra ID and deploying on AWS EKS, I would consider the following options.
1. Use the Mendix Email Connector with OAuth 2.0
Mendix has an Email Connector module that supports OAuth 2.0 authentication with Microsoft Entra ID.
You can explore this option first, as it supports:
SMTP email sending.
OAuth 2.0 Authorization Code Flow.
OAuth 2.0 Client Credentials Flow.
Microsoft Entra ID integration.
For a server-to-server integration where emails are sent without user interaction, Client Credentials Flow would generally be the more suitable option.
The basic implementation would involve:
Register an application in Microsoft Entra ID.
Configure the required Exchange Online API permissions.
For application-based SMTP authentication, configure SMTP.SendAsApp and grant admin consent.
Register the application's service principal in Exchange Online and grant access to the required mailbox.
Configure the OAuth settings in the Mendix Email Connector.
Update your existing email-sending logic to use the connector.
One important consideration: Since you are on Mendix 9.18.2, check the compatibility of the Email Connector version before upgrading or installing the latest version. Test it in a separate environment first.
Documentation:
https://docs.mendix.com/appstore/modules/email-connector/
2. Use an SMTP Proxy Relay (if you want to keep your existing implementation)
If you already have multiple integrations using the existing SMTP configuration and don't want to modify all those microflows, using a proxy relay could be a practical approach.
The architecture would look something like this:
Mendix Application (AWS EKS)
→ Internal SMTP Proxy Relay
→ Microsoft Entra ID (OAuth 2.0 token)
→ Exchange Online (smtp.office365.com)
In this approach:
Mendix continues sending emails through the SMTP interface exposed by the relay.
The relay handles OAuth 2.0 authentication with Microsoft Entra ID.
The relay obtains and refreshes access tokens.
It authenticates with Exchange Online using the XOAUTH2 mechanism.
Your existing Mendix email-sending logic can remain largely unchanged.
However, make sure the relay actually supports OAuth 2.0 for Exchange Online SMTP. A normal SMTP relay that only supports username/password authentication will not solve the problem.
Also, if you are using an Exchange Online SMTP relay connector based on IP or TLS certificate authentication, that is a different authentication mechanism from OAuth 2.0.
3. Things to consider in AWS EKS
Since your application is hosted on EKS, I would also check:
Outbound connectivity from the EKS pods to the SMTP relay.
Network access to Microsoft's OAuth token endpoint.
TLS configuration and certificate validation.
Secure storage of client secrets or certificates using AWS Secrets Manager.
Automatic token renewal and expiration handling.
Proper logging and error handling for failed email deliveries.
My recommendation
If you want to minimize changes to your existing Mendix application, I would lean towards the SMTP proxy relay approach, provided your organization already has a supported relay solution.
If you don't have an existing relay, I would first evaluate the Mendix Email Connector's OAuth support.
One more thing: Your application's existing Entra ID integration for user authentication does not automatically provide OAuth authentication for SMTP. SMTP needs its own application permissions and token configuration.