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:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user