我希望使用php邮件程序调试信息显示在网页中。当我启用调试时,它只是回显字符串。这意味着我的 html 顺序不对,我希望因此输出为变量,以便我可以将输出 html 放置在我想要的地方。
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
PHPMailer 最近的更改允许Debugoutput
是一个闭包,所以你可以让它做任何你喜欢的事情,例如收集所有的调试输出并在以后发出它:
$debug = '';
$mail->Debugoutput = function($str, $level) {
$GLOBALS['debug'] .= "$level: $str'n";
};
//...later
echo $debug;