Settings > Mail - sending (an SMTP server, or Google Workspace / * Microsoft 365 by OAuth), receiving the mailbox email to ticket reads, the * OAuth app both share, the addresses and names emails come from, tests, and * a preview of every email ITFlow sends. Each tab's form saves on its own * (admin/post/settings_mail.php), with the frame's save bar. Passwords, the * OAuth secret and its refresh token are never put back into the page: left * empty, they stay as saved. */ require_once "includes/inc_all_admin.php"; // ---- Tiny status dot for tab labels ---------------------------------------- function renderMailStatusDot($on) { return $on ? '' : ''; } $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); // ---- Active tab ------------------------------------------------------------- // The tab lives in the URL (?tab=receiving) so it can be linked, bookmarked, survives a // reload, and lets the POST handlers send you back to the tab you saved from $mail_tabs = ['sending', 'receiving', 'oauth', 'from', 'tests', 'previews']; $active_tab = isset($_GET['tab']) && in_array($_GET['tab'], $mail_tabs, true) ? $_GET['tab'] : 'sending'; // A direct link to the OAuth tab reveals it even when no OAuth provider is selected yet if ($active_tab === 'oauth') { $oauth_needed = 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; // ---- What the fields offer ------------------------------------------------- // Sending or receiving through - off, a server signed in to with a password, or Google / Microsoft by OAuth $provider_choices = function ($server) { return [ '' => $server === 'smtp' ? 'Off - ITFlow sends no email' : 'Off - no mailbox is read', "standard_$server" => ($server === 'smtp' ? 'An SMTP server' : 'An IMAP server') . ' - with a username and password', 'google_oauth' => 'Google Workspace - signed in with OAuth', 'microsoft_oauth' => 'Microsoft 365 - signed in with OAuth', ]; }; // A server's encryption - and anything else saved long ago, kept as it is until changed $encryption_choices = function ($saved, $starttls_port, $ssl_port) { $choices = ['' => 'None', 'tls' => "STARTTLS - usually port $starttls_port", 'ssl' => "SSL/TLS - usually port $ssl_port"]; if ((string) $saved !== '' && !isset($choices[(string) $saved])) { $choices[(string) $saved] = (string) $saved; } return $choices; }; // A password or secret field says whether one is saved, never what it is $secret_placeholder = function ($saved, $empty) { return trim((string) $saved) !== '' ? 'Saved - type a new one to replace it' : $empty; }; // The OAuth app, as far as it is set up - and what to say about it where a provider uses it $oauth_app_set = !empty($config_mail_oauth_client_id) && !empty($config_mail_oauth_client_secret); $oauth_connected = $oauth_app_set && !empty($config_mail_oauth_refresh_token); $oauth_pointer = function ($server) use ($oauth_connected) { ob_start(); ?>
Every email ITFlow sends, as it goes out - your logo, your details and your From addresses. Each is made just now on sample records (= escapeHtml(EMAIL_PREVIEW_PEOPLE['client']) ?>, its contact = escapeHtml(EMAIL_PREVIEW_PEOPLE['contact'][0]) ?> and an agent, = escapeHtml(EMAIL_PREVIEW_PEOPLE['agent'][0]) ?>) that are thrown away again, so looking sends and saves nothing.