From 5281cec03179e1c2baffcd40afe546c9e959d51a Mon Sep 17 00:00:00 2001 From: Hosteroid Date: Fri, 17 Oct 2025 11:55:25 +0300 Subject: [PATCH] Enable SMTP debug logging for test emails SMTP dialog is now always captured and logged for test emails using PHPMailer::DEBUG_SERVER. This change improves diagnostics by logging detailed SMTP communication without requiring an environment flag. --- app/Helpers/EmailHelper.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Helpers/EmailHelper.php b/app/Helpers/EmailHelper.php index c1206b1..508c5aa 100644 --- a/app/Helpers/EmailHelper.php +++ b/app/Helpers/EmailHelper.php @@ -120,6 +120,14 @@ class EmailHelper $emailSettings = self::getEmailSettings(); $appSettings = self::getAppSettings(); $mail = self::createMailer(); + + // Always capture SMTP dialog for test emails (no env flag needed) + $mail->SMTPDebug = PHPMailer::DEBUG_SERVER; // verbose for diagnostics + $mail->Debugoutput = function($str, $level) { + $lvlMap = [1 => 'CLIENT', 2 => 'SERVER', 3 => 'CONN', 4 => 'LOW']; + $label = $lvlMap[$level] ?? (string)$level; + self::getLogger()->debug('SMTP ' . $label . ': ' . trim($str)); + }; // Set sender $mail->setFrom($emailSettings['mail_from_address'], $emailSettings['mail_from_name']);