Language Change NPM Resource Changed PR-6.2-dev Pending

User tests: Successful: Unsuccessful:

avatar HLeithner
HLeithner
23 Aug 2026

Pull Request resolves #43403 .

This version is party based on #47669 but replaces all the provider specific things. Also fixed the not working parts. Special tanks go to @dawe78 for creating the base implementation.

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

Added the needed fields and endpoints for xoauth2 for smtp.

This implementation has no provider specific presets, instead I will add a detail manual to guide for the microsoft and google implementation.

Testing Instructions

TBA
For now this is a draft, if you know how xoauth2 works the PR is tested with microsoft implementation and is known to work, additional tests are needed.

Actual result BEFORE applying this Pull Request

Not possible to test since it's a new feature

Expected result AFTER applying this Pull Request

Sending works

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • [] Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

Preparation for documentation:

SMTP OAuth 2.0 Configuration in Joomla

Joomla supports OAuth 2.0 authentication for SMTP connections.

Instead of storing the password of the SMTP account, Joomla authorizes access through the mail provider. The provider returns a long-lived refresh token, which Joomla can later use to request short-lived access tokens for SMTP authentication.

The basic flow is:

Joomla
  ↓
OAuth provider authorization page
  ↓
User signs in and grants access
  ↓
Provider redirects back to Joomla
  ↓
Joomla receives an authorization code
  ↓
Joomla exchanges the code for tokens
  ↓
Refresh token is stored
  ↓
Access tokens are created when SMTP authentication is required

The SMTP password is therefore not used for OAuth 2.0 authentication.


Before you start

The setup consists of several steps.

  1. Create or register an OAuth application with your mail provider.
  2. Configure the application's allowed redirect URI.
  3. Configure the required SMTP permissions or OAuth scopes.
  4. Create a Client ID and Client Secret.
  5. If required by the provider, publish, deploy, or activate the OAuth application.
  6. Wait until provider-side changes have propagated. Depending on the provider and tenant configuration, this can take up to approximately one hour.
  7. Enter the OAuth settings in Joomla.
  8. Save the Joomla configuration.
  9. Start the OAuth authorization from Joomla.
  10. Sign in to the SMTP account and grant the requested permission.
  11. Verify that Joomla received and stored a refresh token.
  12. Send a test email.

Do not assume that a newly created or modified OAuth application is immediately usable. Provider-side configuration changes can take some time to become effective.


Joomla OAuth 2.0 settings

Open:

System
→ Global Configuration
→ Server
→ Mail

Select:

Mailer: SMTP
SMTP Authentication: OAuth 2.0

Joomla then displays the OAuth 2.0 configuration fields.

From Email Address

The configured From Email Address should match the mailbox used as the SMTP username.

Example:

From Email Address:
user@example.com

SMTP Username:
user@example.com

For the standard OAuth 2.0 SMTP setup, both values should refer to the same mailbox.

Using a different From address can require additional provider-side permissions such as Send As, aliases, or delegated mailbox permissions and may otherwise cause the provider to reject the message.


SMTP Username

The SMTP username identifies the mailbox Joomla uses for SMTP authentication.

Usually this is the complete email address:

user@example.com

The account authorized during the OAuth flow should normally be the same account.


OAuth2 Client ID

The Client ID identifies the OAuth application registered with the mail provider.

It is generated by the provider when the OAuth application or OAuth client is created.

Example:

aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee

The Client ID is not a secret.


OAuth2 Client Secret

The Client Secret authenticates the Joomla OAuth application to the provider.

It is created by the provider together with, or after creating, the OAuth application.

Example:

OAuth2 Client Secret:
••••••••••••••••

The Client Secret must be kept private.

It should not be:

  • published
  • committed to a public repository
  • included in documentation
  • shared between unrelated Joomla installations unless intentionally using the same OAuth application

OAuth2 Scope

The scope tells the provider which permissions Joomla requests.

Scopes are provider-specific.

For SMTP authentication, the scope usually grants permission to access or send mail through the user's mailbox.

One or more scopes can be requested.

If multiple scopes are required, they are normally separated by spaces:

scope1 scope2 scope3

The exact scope value depends on the mail provider.


OAuth2 Authorize URL

The Authorize URL is the provider endpoint where the user signs in and grants Joomla access.

Joomla redirects the administrator to this URL when OAuth authorization is started.

The provider then:

  1. authenticates the user
  2. displays the requested permissions
  3. asks for consent if required
  4. redirects the browser back to Joomla

The exact URL depends on the provider.


OAuth2 Token URL

The Token URL is the provider endpoint Joomla uses to exchange OAuth credentials.

It is used for two important operations.

First, after authorization:

authorization code
    ↓
token endpoint
    ↓
access token + refresh token

Later:

refresh token
    ↓
token endpoint
    ↓
new access token

The administrator normally never interacts with this endpoint directly.


OAuth redirect URI

OAuth providers require Joomla's callback URL to be registered with the OAuth application.

For Joomla, the callback URL is:

https://www.example.com/administrator/index.php?option=com_config&task=mail.oauth2callback&format=raw

Replace:

https://www.example.com

with the actual Joomla site URL.

The redirect URI configured at the provider must match the URI Joomla sends during authorization.

In particular, check:

  • protocol
  • hostname
  • path
  • query string
  • Joomla administrator path

For example:

https://example.com/administrator/index.php?option=com_config&task=mail.oauth2callback&format=raw

and:

https://www.example.com/administrator/index.php?option=com_config&task=mail.oauth2callback&format=raw

are different redirect URIs.


Microsoft 365

TL;DR

For a typical single-tenant Microsoft 365 setup, use:

SMTP Host:
smtp.office365.com

SMTP Port:
587

SMTP Security:
STARTTLS

SMTP Authentication:
OAuth 2.0

From Email Address:
user@example.com

SMTP Username:
user@example.com

OAuth2 Client ID:
<Application (client) ID>

OAuth2 Client Secret:
<Client Secret Value>

OAuth2 Scope:
https://outlook.office.com/SMTP.Send offline_access

OAuth2 Authorize URL:
https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/authorize

OAuth2 Token URL:
https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/token

Register this redirect URI in Microsoft Entra:

https://www.example.com/administrator/index.php?option=com_config&task=mail.oauth2callback&format=raw

Also make sure Authenticated SMTP is enabled for the mailbox.

After changing the application, permissions, or Exchange settings, allow up to approximately one hour for changes to propagate.


Overview

The Microsoft setup consists of:

  1. Register an application in Microsoft Entra.
  2. Configure the Joomla redirect URI.
  3. Configure delegated SMTP permissions.
  4. Create a Client Secret.
  5. Make sure SMTP AUTH is enabled for the mailbox.
  6. Wait for configuration changes to propagate if necessary.
  7. Enter the application settings in Joomla.
  8. Authorize the mailbox through Joomla.

Changes to application registrations, permissions, consent, or Exchange settings may not become effective immediately. In some environments, propagation can take up to approximately one hour.


1. Register the application

Open the Microsoft Entra admin center.

Navigate to:

Identity
→ Applications
→ App registrations
→ New registration

Enter a name such as:

Joomla SMTP OAuth

For a Joomla installation used with one Microsoft 365 organization, a single-tenant registration is normally appropriate:

Accounts in this organizational directory only

After registration, note:

Application (client) ID
Directory (tenant) ID

Both values are available on the application's Overview page.


2. Configure the redirect URI

Open:

App registrations
→ Joomla SMTP OAuth
→ Authentication

Add a platform:

Web

Register the Joomla callback URL:

https://www.example.com/administrator/index.php?option=com_config&task=mail.oauth2callback&format=raw

Use the real Joomla site URL.


3. Configure SMTP permissions

Joomla requires delegated SMTP access.

The SMTP permission is:

https://outlook.office.com/SMTP.Send

Joomla also requires a refresh token so that SMTP authentication continues to work without the administrator signing in again.

Therefore the Joomla scope should include:

offline_access

The final scope is:

https://outlook.office.com/SMTP.Send offline_access

Depending on the organization's Microsoft Entra policies, administrator consent may be required.


4. Create the Client Secret

Navigate to:

App registrations
→ Joomla SMTP OAuth
→ Certificates & secrets
→ Client secrets
→ New client secret

Create a secret.

Microsoft displays values such as:

Secret ID
Value

Joomla requires the actual:

Value

Do not enter the Secret ID.

Store the secret immediately because Microsoft may only display the value once.


5. Enable SMTP AUTH

OAuth authorization alone is not sufficient if SMTP AUTH is disabled for the mailbox.

In the Microsoft 365 admin center, check the affected user.

Navigate approximately to:

Users
→ Active users
→ User
→ Mail
→ Manage email apps

Ensure:

Authenticated SMTP

is enabled.

Organization-wide Exchange Online policies or Microsoft security settings can also disable SMTP AUTH.

If the OAuth flow succeeds but SMTP still fails, this setting should be one of the first things to verify.

Changes to Exchange or mailbox settings can take some time to propagate.


6. Configure Joomla

Use:

SMTP Host:
smtp.office365.com

SMTP Port:
587

SMTP Security:
STARTTLS

SMTP Authentication:
OAuth 2.0

From Email Address:
user@example.com

SMTP Username:
user@example.com

The From Email Address and SMTP Username should normally be identical.

Using a different sender address can require additional Microsoft 365 permissions such as Send As.

OAuth2 Client ID

Use the:

Application (client) ID

from the Entra application.

OAuth2 Client Secret

Use the Client Secret Value.

OAuth2 Scope

https://outlook.office.com/SMTP.Send offline_access

OAuth2 Authorize URL

For a single-tenant application:

https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/authorize

Replace TENANT_ID with the Directory (tenant) ID.

OAuth2 Token URL

https://login.microsoftonline.com/TENANT_ID/oauth2/v2.0/token

Use the same tenant ID.


7. Authorize the account

Save the Joomla configuration.

Start OAuth authorization.

Joomla redirects the browser to Microsoft.

Sign in using the account configured as:

SMTP Username

Approve the requested permissions.

Microsoft redirects the browser back to Joomla.

Joomla then exchanges the authorization code for OAuth tokens and stores the refresh token.

Afterwards Joomla can obtain new access tokens without requiring an interactive login.


Google Gmail and Google Workspace

TL;DR

For Gmail or Google Workspace, use:

SMTP Host:
smtp.gmail.com

SMTP Port:
587

SMTP Security:
STARTTLS

SMTP Authentication:
OAuth 2.0

From Email Address:
user@example.com

SMTP Username:
user@example.com

OAuth2 Client ID:
<Google OAuth Client ID>

OAuth2 Client Secret:
<Google OAuth Client Secret>

OAuth2 Scope:
https://mail.google.com/

OAuth2 Authorize URL:
https://accounts.google.com/o/oauth2/v2/auth

OAuth2 Token URL:
https://oauth2.googleapis.com/token

Register this redirect URI for the Google OAuth client:

https://www.example.com/administrator/index.php?option=com_config&task=mail.oauth2callback&format=raw

The OAuth client must use the application type:

Web application

Depending on the audience, publishing status, test-user configuration, and requested scopes, the OAuth application may need to be published or otherwise made available to the SMTP user.

After changing the OAuth application configuration, allow up to approximately one hour for changes to propagate.


Overview

The Google setup consists of:

  1. Create or select a Google Cloud project.
  2. Configure Google Auth Platform / OAuth consent.
  3. Configure the required Gmail scope.
  4. Create a Web OAuth client.
  5. Configure the Joomla redirect URI.
  6. Publish or make the OAuth application available to the intended users.
  7. Wait for configuration changes to propagate if necessary.
  8. Enter the OAuth client information in Joomla.
  9. Authorize the Gmail or Google Workspace account.

Changes to Google OAuth configuration, consent configuration, scopes, test-user configuration, or application publishing may not become effective immediately. In some cases, allow up to approximately one hour before treating a configuration as broken.


1. Create or select a Google Cloud project

Open Google Cloud Console.

Create a new project or select an existing project intended for the Joomla installation.

The OAuth configuration and credentials belong to this project.


2. Configure Google Auth Platform

Open:

Google Auth Platform

Configure the application's:

Branding
Audience
Data Access

At minimum configure:

  • application name
  • support email
  • developer contact
  • intended audience

For a Google Workspace organization, an application intended only for users inside the organization can normally use an internal audience.

For external applications, configure the appropriate publishing status and test users.


3. Configure the Gmail scope

For Gmail SMTP OAuth access, use:

https://mail.google.com/

This grants OAuth access required for Gmail SMTP authentication.

The scope is considered sensitive or restricted by Google, so additional Google verification requirements can apply to public applications.

For private organizational use, particularly with Google Workspace, the requirements can differ.


4. Create the OAuth client

Open:

Google Auth Platform
→ Clients

Create a new OAuth client.

Choose:

Web application

Joomla is a server-side web application and requires a Web OAuth client.


5. Configure the redirect URI

Under the OAuth client, add the authorized redirect URI:

https://www.example.com/administrator/index.php?option=com_config&task=mail.oauth2callback&format=raw

Use the exact Joomla URL.

The complete callback URL must be registered.

Registering only:

https://www.example.com

is not sufficient.


6. Publish or enable the application

Depending on the configured audience and Google account type, the application may need to be published or users may need to be explicitly added as test users.

Before troubleshooting Joomla, verify that the account used for SMTP is actually allowed to authorize the OAuth application.

After changing:

  • audience
  • test users
  • requested scopes
  • publishing status
  • OAuth client configuration

allow some time for the changes to propagate.

In some cases this can take up to approximately one hour.


7. Copy the OAuth credentials

Google provides:

Client ID
Client Secret

A Google Client ID normally looks similar to:

123456789012-example.apps.googleusercontent.com

Copy both values into Joomla.

Keep the Client Secret private.


8. Configure Joomla

Use:

SMTP Host:
smtp.gmail.com

SMTP Port:
587

SMTP Security:
STARTTLS

SMTP Authentication:
OAuth 2.0

From Email Address:
user@example.com

SMTP Username:
user@example.com

The From Email Address and SMTP Username should normally be identical.

Using a different sender address can require additional alias or delegation configuration in Google Workspace or Gmail.

OAuth2 Client ID

Use the OAuth Client ID created in Google Cloud.

OAuth2 Client Secret

Use the secret created for the Google OAuth client.

OAuth2 Scope

https://mail.google.com/

OAuth2 Authorize URL

https://accounts.google.com/o/oauth2/v2/auth

OAuth2 Token URL

https://oauth2.googleapis.com/token

9. Authorize the account

Save the Joomla configuration.

Start OAuth authorization.

Joomla redirects the administrator to Google.

Sign in using the Gmail or Google Workspace account configured as:

SMTP Username

Approve the requested Gmail permission.

Google redirects back to Joomla.

Joomla exchanges the authorization code for OAuth tokens and stores the refresh token.

The refresh token is then used to request new short-lived access tokens whenever SMTP authentication is required.


Final check

After the setup is complete, verify the following:

  • SMTP authentication is set to OAuth 2.0.
  • From Email Address matches the SMTP username.
  • SMTP username matches the authorized mailbox.
  • Client ID is correct.
  • Client Secret is correct.
  • Scope matches the provider.
  • Authorization URL is correct.
  • Token URL is correct.
  • Joomla callback URL is registered exactly at the provider.
  • The OAuth application is enabled or published for the affected user.
  • Provider-side changes had enough time to propagate.
  • Joomla successfully completed OAuth authorization.
  • Joomla received a refresh token.
  • A Joomla test email can be sent successfully.
avatar HLeithner HLeithner - open - 23 Aug 2026
avatar HLeithner HLeithner - change - 23 Aug 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 23 Aug 2026
Category Administration com_config Language & Strings Layout Libraries JavaScript NPM Change
avatar HLeithner HLeithner - change - 23 Aug 2026
Labels Added: Language Change NPM Resource Changed PR-6.2-dev
avatar HLeithner
HLeithner - comment - 25 Aug 2026

I think we need better codestyle checker ;-) thanks @QuyTon

avatar brianteeman
brianteeman - comment - 25 Aug 2026

took me a while as the test instructions are a bit too brief but I got there in the end and successfully sent email throguh google.

Only problem I had which I have not resolved is that I got a 403 when trying to get the token. I disabled my admintools generated htaccess in order to get the token. But I dont know what it was in the htaccess that caused the 403

avatar brianteeman
brianteeman - comment - 25 Aug 2026

Google Workspace Setup etc

  1. Go to the [Google Cloud Console](https://console.cloud.google.com/).

  2. Create a new Google Cloud project. Give it something obvious such as:

    Joomla Gmail OAuth Test

    You don't need to create anything else in the project; the project is essentially the container for your OAuth credentials.

  3. In the Google Cloud Console, go to:

    Google Auth Platform → Branding

    If Google asks you to configure Google Auth Platform, click Get Started.

    Enter an application name such as:

    Joomla Mail OAuth Test

    and your support email address. Google documents this current flow under the Google Auth Platform configuration.

  4. Go to Google Auth Platform → Audience.

    Because you're using Google Workspace, you will probably want:

    Internal

    if the Joomla site will only authenticate accounts belonging to your Workspace organisation.

    This is particularly useful for testing because internal applications don't have the same external-app verification requirements. Google confirms that restricted/sensitive scopes used only internally within a Workspace organisation don't require Google's additional verification.

  5. Go to Google Auth Platform → Data Access.

    Add this scope:

    https://mail.google.com/

    There is an important caveat here: Google's current guidance considers https://mail.google.com/ a restricted scope. For SMTP/IMAP, Google says it is the full-mail scope, but recommends more limited Gmail API scopes where possible. If Joomla is actually using SMTP with OAuth/XOAUTH2, however, this broad scope is the one your instructions are specifying.

  6. Now go to:

    Google Auth Platform → Clients

    Click Create Client.

    Choose:

    Application type: Web application

    Google specifically says that server-side applications should use a Web application client and that the OAuth redirect URI must be registered against that client.

  7. Give the client a name, for example:

    Joomla Mail

  8. Under Authorized redirect URIs, add the callback URL from your Joomla instructions.

    For example, if your Joomla site is:

    https://example.com

    enter:

    https://example.com/administrator/index.php?option=com_config&task=mail.oauth2callback&format=raw

    Don't alter this URL. In particular, the query string is part of the redirect URI.

    Google requires the redirect URI used by Joomla to exactly match one of the authorized redirect URIs configured for the OAuth client. Otherwise you'll get the dreaded:

    redirect_uri_mismatch

    error. Google also notes that changes to OAuth client settings can take from several minutes to a few hours to propagate.

  9. Click Create.
    Google will give you two important values:

    Client ID

    Client secret

    Google warns that the client secret is only displayed after creation, so save it securely.

  10. Configure mail in Joomla configuration

So your Joomla mail configuration would typically be:

SMTP Host: smtp.gmail.com
SMTP Port: 587
Encryption: TLS / STARTTLS
Authentication: XOAUTH2
Username: brian@example.com
Password:
OAuth Client ID: [Google Client ID]
OAuth Client Secret: [Google Client Secret]

  1. Get your token
  2. Validate your token
  3. Send a test mail
avatar HLeithner HLeithner - change - 25 Aug 2026
The description was changed
avatar HLeithner HLeithner - edited - 25 Aug 2026
avatar HLeithner HLeithner - change - 25 Aug 2026
The description was changed
avatar HLeithner HLeithner - edited - 25 Aug 2026
avatar HLeithner
HLeithner - comment - 25 Aug 2026

Google Workspace Setup etc

...
13. Send a test mail

I added a documentation in the pr now, which should be used later on guide.joomla.org

avatar brianteeman
brianteeman - comment - 1 Sep 2026

@HLeithner after the recent changes do i need to retest this against google? Sorry I dont have any ms accounts to test with

avatar HLeithner
HLeithner - comment - 1 Sep 2026

@HLeithner after the recent changes do i need to retest this against google? Sorry I dont have any ms accounts to test with

would be great but I think the changes are minor enough if you don't have time now.

avatar brianteeman
brianteeman - comment - 1 Sep 2026

Would it be possible to add a message that you need to Save before you can complete and get the tokens or to change the xisting message as I have obviously got a clientid

image
avatar TLWebdesign TLWebdesign - test_item - 1 Sep 2026 - Tested successfully
avatar TLWebdesign
TLWebdesign - comment - 1 Sep 2026

I have tested this item ✅ successfully on d8b1db5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48290.

avatar TLWebdesign
TLWebdesign - comment - 1 Sep 2026

I have tested this item ✅ successfully on d8b1db5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48290.

avatar TLWebdesign
TLWebdesign - comment - 1 Sep 2026

I tested succesfully using microsoft 365 client of mine.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48290.

avatar TLWebdesign
TLWebdesign - comment - 1 Sep 2026

I tested succesfully using microsoft 365 client of mine.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48290.

avatar brianteeman
brianteeman - comment - 1 Sep 2026

@HLeithner after the recent changes do i need to retest this against google? Sorry I dont have any ms accounts to test with

would be great but I think the changes are minor enough if you don't have time now.

still works

avatar MacJoom MacJoom - test_item - 1 Sep 2026 - Tested successfully
avatar MacJoom
MacJoom - comment - 1 Sep 2026

I have tested this item ✅ successfully on d8b1db5

Tested with my community.joomla.org account


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48290.

avatar MacJoom
MacJoom - comment - 1 Sep 2026

I have tested this item ✅ successfully on d8b1db5

Tested with my community.joomla.org account


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48290.

avatar MacJoom
MacJoom - comment - 1 Sep 2026

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48290.

avatar MacJoom
MacJoom - comment - 1 Sep 2026

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48290.

avatar MacJoom MacJoom - change - 1 Sep 2026
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2026-09-01 11:42:43
Closed_By MacJoom
avatar MacJoom MacJoom - close - 1 Sep 2026
avatar MacJoom MacJoom - merge - 1 Sep 2026
avatar MacJoom
MacJoom - comment - 1 Sep 2026

Thank you very much!

avatar HLeithner
HLeithner - comment - 1 Sep 2026

thank you all.

Add a Comment

Login with GitHub to post a comment