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.
This commit is contained in:
Hosteroid
2025-10-17 11:55:25 +03:00
parent c28ec4921e
commit 5281cec031

View File

@@ -120,6 +120,14 @@ class EmailHelper
$emailSettings = self::getEmailSettings(); $emailSettings = self::getEmailSettings();
$appSettings = self::getAppSettings(); $appSettings = self::getAppSettings();
$mail = self::createMailer(); $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 // Set sender
$mail->setFrom($emailSettings['mail_from_address'], $emailSettings['mail_from_name']); $mail->setFrom($emailSettings['mail_from_address'], $emailSettings['mail_from_name']);