Essential Configuration
After completing the Azure Configuration, you need to configure the TYPO3 extension with the values obtained from Microsoft Entra ID.
Attention
The Client ID can be found on the overview page in Azure and should not be confused with the Client Secret ID. For the secret configuration, only the Secret value itself is required, not the Secret ID.
Configuration Variables
The extension reads its settings from $GLOBALS. The
keys are prefixed with transport_ to avoid conflicts with other mail
transports. These settings are used everywhere — backend, CLI, scheduler and, unless
TypoScript overrides them, the frontend.
The steps below write them as environment variables named
TYPO3_, which keeps every secret out of files that end up in
version control.
Important
TYPO3 does not read TYPO3_ variables by itself. The
double-underscore naming is a widespread convention, but the mapping onto
$GLOBALS has to be done by your project — see
Mapping TYPO3_CONF_VARS__… variables. If your project has no such mapping, use
In TYPO3 configuration files, reading the environment instead.
-
Set the mail transport to Exchange365Transport.
Configure TYPO3 to use the Exchange 365 transport instead of the default SMTP transport.
TYPO3_CONF_VARS__MAIL__transport=OliverKroener\\OkExchange365\\Mail\\Transport\\Exchange365TransportCopied! -
Configure the Tenant ID.
Set the Tenant ID obtained from step 4 of the Azure Configuration.
TYPO3_CONF_VARS__MAIL__transport_exchange365_tenantId='your-tenant-id-here'Copied!Attention
Replace
your-with the actual Tenant ID from your Azure application overview page.tenant- id- here -
Configure the Client ID.
Set the Client ID (Application ID) obtained from step 4 of the Azure Configuration.
TYPO3_CONF_VARS__MAIL__transport_exchange365_clientId='your-client-id-here'Copied!Attention
Replace
your-with the actual Client ID from your Azure application overview page.client- id- here -
Configure the Client Secret.
Set the Client Secret value obtained from step 7 of the Azure Configuration.
TYPO3_CONF_VARS__MAIL__transport_exchange365_clientSecret='your-client-secret-here'Copied!Attention
- Replace
your-with the actual Secret Value (not the Secret ID)client- secret- here - This is sensitive information - keep it secure and never expose it in public repositories
- Replace
-
Configure the sender email address.
Set the email address that will be used as the sender for all emails sent through this transport.
TYPO3_CONF_VARS__MAIL__transport_exchange365_fromEmail='service@your-domain.com'Copied!Attention
The email address will fall back to TYPO3's
$GLOBALSif not specified here.['TYPO3_ CONF_ VARS'] ['MAIL'] ['default Mail From Address'] Note
- Replace
service@your-with a valid email address from your organization (it must exist in your Exchange 365 environment as SharedMailbox or User Mailbox)domain. com - This email address must exist in your Exchange 365 environment
- The application needs permission to send emails on behalf of this address
- Replace
-
Configure the Graph sender user ID (optional).
Set the Microsoft Graph mailbox/user ID used for the API call. This is resolved separately from the message From address, so you can send as or on behalf of a different mailbox (Send As / Send On Behalf scenarios).
TYPO3_CONF_VARS__MAIL__transport_exchange365_graphSenderUserId='shared-mailbox@your-domain.com'Copied!Note
- Leave empty to fall back to the message From address, then to
from, then toEmail $GLOBALS['TYPO3_ CONF_ VARS'] ['MAIL'] ['default Mail From Address'] - The mailbox must exist in your Exchange 365 environment and the Azure application must have
Mail.permission for itSend - This mailbox needs Send As or Send On Behalf on the visible sender mailbox. See Send mail from another user (Microsoft Graph).
- Leave empty to fall back to the message From address, then to
-
Save to Sent Items (no effect on this version).
The 2.x line posts the raw MIME message to the Graph
sendendpoint. In that mode, Microsoft Graph always saves a copy in the Sent Items folder of the mailbox the call is made through.Mail transport_(defaultexchange365_ save To Sent Items 0) is therefore ignored on this version, and the static template has nosaveconstant.To Sent Items
Configuration Example
Here's a complete example of all required configuration variables:
Environment Variables (.env file)
You can configure these settings using a .env file in your TYPO3 root directory:
# Exchange 365 Mail Transport Configuration
TYPO3_CONF_VARS__MAIL__transport=OliverKroener\\OkExchange365\\Mail\\Transport\\Exchange365Transport
TYPO3_CONF_VARS__MAIL__transport_exchange365_tenantId='your-tenant-id-here'
TYPO3_CONF_VARS__MAIL__transport_exchange365_clientId='your-client-id-here'
TYPO3_CONF_VARS__MAIL__transport_exchange365_clientSecret='your-client-secret-here'
TYPO3_CONF_VARS__MAIL__transport_exchange365_fromEmail='service@your-domain.com'
# Optional: Send As / Send On Behalf (leave unset to use the message From)
#TYPO3_CONF_VARS__MAIL__transport_exchange365_graphSenderUserId='shared-mailbox@your-domain.com'
Alternative Configuration Methods
Mapping TYPO3_CONF_VARS__… variables
If your project does not already map TYPO3_ environment variables,
add this loop. Double underscores become array levels, so
TYPO3_ ends up in
$GLOBALS.
<?php
// Variables loaded by a dotenv library live in $_ENV, variables set by the
// web server or container in getenv(). Read both.
foreach (array_merge(getenv(), $_ENV) as $name => $value) {
if (!is_string($name) || strpos($name, 'TYPO3_CONF_VARS__') !== 0) {
continue;
}
$target = &$GLOBALS['TYPO3_CONF_VARS'];
foreach (explode('__', substr($name, strlen('TYPO3_CONF_VARS__'))) as $segment) {
$target = &$target[$segment];
}
$target = $value;
unset($target);
}
In TYPO3 configuration files, reading the environment
Without the mapping, set the values in
public/ and read the secrets from the
environment there. Use your own variable names:
<?php
$env = static function (string $name): string {
return (string)(getenv($name) ?: ($_ENV[$name] ?? ''));
};
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport'] = \OliverKroener\OkExchange365\Mail\Transport\Exchange365Transport::class;
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_exchange365_tenantId'] = $env('EXCHANGE365_TENANT_ID');
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_exchange365_clientId'] = $env('EXCHANGE365_CLIENT_ID');
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_exchange365_clientSecret'] = $env('EXCHANGE365_CLIENT_SECRET');
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_exchange365_fromEmail'] = 'service@your-domain.com';
// Optional: distinct Graph sender mailbox (Send As / Send On Behalf).
// $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_exchange365_graphSenderUserId'] = 'account1@your-domain.com';
Warning
Do not write the client secret as a literal into Local
or Additional. TYPO3 rewrites
Local when settings change in the backend, and both
files typically end up in version control and backups.
Note
In the frontend, the same values can also come from TypoScript, where
:= get reads them from the environment. See Recommended: read the credentials from the environment.
Testing the Configuration
After configuring all variables, you can test the email functionality by:
- Sending a test email through TYPO3's mail functionality
- Checking the TYPO3 logs for any error messages
- Verifying that emails are received at the intended recipients
Tip
Enable TYPO3's developer log to see detailed information about the email sending process and any potential issues with the Exchange 365 integration.
Security Considerations
Warning
Azure Credential Security
- Store the
clientsecurely using environment variables or encrypted configurationSecret - Never commit secrets to version control systems
- Rotate client secrets regularly before expiration
- Use different Azure applications for different environments (dev/staging/prod)
- Monitor Azure sign-in logs for unauthorized access
Note
In System > Configuration, the extension masks the tenant ID, client ID and
client secret held in TYPO3_ (via a hook of the lowlevel
configuration module). Other places, such as TypoScript, are not masked.
Configuration Validation
To verify your configuration is correct:
-
Check in backend:
- Open Admin Tools > Environment > Test Mail Setup and send a test mail
- Ensure the transport is set to
Exchange365Transportand all required fields are filled
-
Check TYPO3 configuration:
// In TYPO3 backend or debug context \TYPO3\CMS\Core\Utility\DebugUtility::debug($GLOBALS['TYPO3_CONF_VARS']['MAIL']);Copied! -
Test email sending:
// Test email functionality $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class); $mail->to('test@example.com') ->subject('Test Email') ->text('This is a test email from TYPO3.') ->send();Copied! - Check logs: Monitor TYPO3 logs for authentication or sending errors.
A failed send throws a Symfony
Transport(aException Runtime) whose message names the cause, for exampleException Exchange 365 configuration missing required field: client.Secret
Automated tests
This branch is covered by the cross-version test matrix that lives on the
extension's main branch (make test- / make test- there).
For TYPO3 v10 it runs the unit and functional tests, PHPStan and the coding
standard check, sends real mail through Microsoft Graph from the CLI and from the
frontend (credentials via := get), and checks in a headless browser that
the credentials are masked in the backend.