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:
@@ -121,6 +121,14 @@ class EmailHelper
|
|||||||
$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']);
|
||||||
$mail->addAddress($toEmail);
|
$mail->addAddress($toEmail);
|
||||||
|
|||||||
Reference in New Issue
Block a user