Hello,
For troubleshooting purposes, please, try setting mail settings using the below script. If it completes with the Mail settings not saved message, please, send us (support@adaxes.com) the output file. If the script is executed successfully, try testing the mail settings in the Administration console. The script should be executed in PowerShell 7 on the computer where Adaxes service runs. In the script:
- $reportFilePath – the path to a text file that will be created by the script in case of any issue saving mail settings.
- $clientId - the Application (client) ID of the Microsoft Entra app.
- $tenantId - the Directory (tenant) ID of the Microsoft Entra app.
- $clientSecret - the client secret of the Microsoft Entra app.
- $from - the From address you used in mail settings (starts with do-not-reply according to your screenshot).
Import-Module Adaxes
$reportFilePath = "C:\Scripts\Report.txt" # TODO: modify me
$clientId = "<clientId>" # TODO: modify me
$tenantId = "<tenantId>" # TODO: modify me
$clientSecret = "<clientSecret>" # TODO: modify me
$from = "<from>" # TODO: modify me
$smptServer = "smtp.office365.com"
$port = "587"
# Connect to the Adaxes service.
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the Service Settings container.
$wellknownContainerPath = $service.Backend.GetConfigurationContainerPath("ServiceSettings")
$serviceSettings = $service.OpenObject($wellknownContainerPath, $null, $null, 0)
# Get mail settings
$mailSettings = $serviceSettings.MailSettings
# Set MailSettings
$mailSettings.Host = $smptServer
$mailSettings.Port = $port
$mailSettings.From = $from
# Create the credentials object.
$credentials = New-Object "Softerra.Adaxes.Management.AdmSmtpEntraIdAuth"
$credentials.ClientId = $clientId
$credentials.TenantId = $tenantId
$credentials.ClientSecret = $clientSecret
# Set credentials.
$mailSettings.SmtpAuth = $credentials
$validationErrors = @()
try
{
$mailSettings.ValidateAuthentication($credentials)
}
catch
{
$validationErrors += "ValidateAuthentication: " + $_.Exception.Message
}
try
{
$mailSettings.ValidateSmtpServer($smptServer, $port)
}
catch
{
$validationErrors += "ValidateSmtpServer: " + $_.Exception.Message
}
try
{
$mailSettings.ValidateFromMail($from)
}
catch
{
$validationErrors += "ValidateFromMail: " + $_.Exception.Message
}
if ($validationErrors.Length -gt 0)
{
$validationErrors | %{$_ | Out-File $reportFilePath -Append}
Write-Warning "Mail settings not saved. See $reportFilePath."
return
}
# Save changes
$mailSettings.Save()
Write-Host "Mail settings saved successfully." -ForegroundColor Green