From 298569a2c26553e2e1ca08e92f43247cda99978e Mon Sep 17 00:00:00 2001 From: johnnyq Date: Thu, 25 Jun 2026 15:49:09 -0400 Subject: [PATCH] Mail Setting UI: Rework the entire Mail Configuration --- admin/settings_mail.php | 967 ++++++++++++++++++---------------------- 1 file changed, 445 insertions(+), 522 deletions(-) diff --git a/admin/settings_mail.php b/admin/settings_mail.php index f66f2b8e..806119ec 100644 --- a/admin/settings_mail.php +++ b/admin/settings_mail.php @@ -1,601 +1,524 @@ -
-
-

SMTP Mail Settings (For Sending Email)

-
-
-
- +// ---- Tiny status dot for tab labels ---------------------------------------- +function mail_status_dot($on) { + return $on + ? '' + : ''; +} - -
- -
-
- -
- -
- - Choose your SMTP provider. OAuth options ignore the SMTP password here. - -
+$smtp_on = !empty($config_smtp_provider); +$imap_on = !empty($config_imap_provider); +$oauth_needed = in_array($config_smtp_provider, ['google_oauth', 'microsoft_oauth'], true) + || in_array($config_imap_provider, ['google_oauth', 'microsoft_oauth'], true); +// ---- OAuth callback URI (for Entra App Registration) ------------------------ +if (defined('BASE_URL') && !empty(BASE_URL)) { + $mail_oauth_callback_uri = rtrim((string) BASE_URL, '/') . '/admin/oauth_microsoft_mail_callback.php'; +} else { + $mail_oauth_callback_uri = 'https://' . rtrim((string) $config_base_url, '/') . '/admin/oauth_microsoft_mail_callback.php'; +} - -
-
- -
-
- -
- -
-
+// ---- Readiness checks (drive the Tests tab) -------------------------------- +$smtp_standard_ready = !empty($config_smtp_host) && !empty($config_smtp_port) + && !empty($config_mail_from_email) && !empty($config_mail_from_name); + +$smtp_oauth_ready = in_array($config_smtp_provider, ['google_oauth', 'microsoft_oauth'], true) + && !empty($config_mail_from_email) && !empty($config_mail_from_name) + && !empty($config_mail_oauth_client_id) && !empty($config_mail_oauth_client_secret) + && !empty($config_mail_oauth_refresh_token) + && ($config_smtp_provider !== 'microsoft_oauth' || !empty($config_mail_oauth_tenant_id)); + +$imap_standard_ready = !empty($config_imap_username) && !empty($config_imap_password) + && !empty($config_imap_host) && !empty($config_imap_port); + +$imap_oauth_ready = in_array($config_imap_provider, ['google_oauth', 'microsoft_oauth'], true) + && !empty($config_imap_username) + && !empty($config_mail_oauth_client_id) && !empty($config_mail_oauth_client_secret) + && !empty($config_mail_oauth_refresh_token) + && ($config_imap_provider !== 'microsoft_oauth' || !empty($config_mail_oauth_tenant_id)); + +$oauth_provider_for_test = ''; +if (in_array($config_imap_provider, ['google_oauth', 'microsoft_oauth'], true)) { + $oauth_provider_for_test = $config_imap_provider; +} elseif (in_array($config_smtp_provider, ['google_oauth', 'microsoft_oauth'], true)) { + $oauth_provider_for_test = $config_smtp_provider; +} + +$oauth_has_required_fields = !empty($oauth_provider_for_test) + && !empty($config_mail_oauth_client_id) && !empty($config_mail_oauth_client_secret) + && !empty($config_mail_oauth_refresh_token) + && ($oauth_provider_for_test !== 'microsoft_oauth' || !empty($config_mail_oauth_tenant_id)); + +$send_ready = $smtp_standard_ready || $smtp_oauth_ready; +$imap_ready = $imap_standard_ready || $imap_oauth_ready; +?> + +
+
+

Mail Configuration

+
+
+ + + +
+ + +
+ +
- +
-
- -
- -
-
- -
- -
-
- -
- + + + +
+ Choose your outbound mail provider.
-
- -
-
- +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
-
-
-
+
+
+ +
+
+ +
+ Leave blank if no authentication is required. +
+
-
- -
- -
- -
+
+ +
-
- - - - -
- - - - -
-
- -
-
-

IMAP Mail Settings (For Monitoring Ticket Inbox)

-
-
-
- - -
- -
-
- -
- -
- - Select your mailbox provider. OAuth options ignore the IMAP password here. - -
-