Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
phpmailer调试输出到html变量_Php_Html_Phpmailer - Fatal编程技术网

phpmailer调试输出到html变量

phpmailer调试输出到html变量,php,html,phpmailer,Php,Html,Phpmailer,我期待着使用php邮件调试信息显示在网页上。当我启用调试时,它只是回显字符串。这意味着我的html是无序的,我希望输出为一个变量,这样我就可以把输出html放在我想要的地方 $mail->SMTPDebug = 2; $mail->Debugoutput = 'html'; PHPMailer中最近的一项更改,因此您可以让它执行任何您喜欢的操作,例如收集所有调试输出并稍后发出: $debug = ''; $mail->Debugoutput = function($str,

我期待着使用php邮件调试信息显示在网页上。当我启用调试时,它只是回显字符串。这意味着我的html是无序的,我希望输出为一个变量,这样我就可以把输出html放在我想要的地方

$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';

PHPMailer中最近的一项更改,因此您可以让它执行任何您喜欢的操作,例如收集所有调试输出并稍后发出:

$debug = '';
$mail->Debugoutput = function($str, $level) {
    $GLOBALS['debug'] .= "$level: $str\n";
};
//...later
echo $debug;

这不是缺少一个
}
之后?除非我遗漏了什么,否则PHPMailer中当前似乎有一个bug,上面函数中的$str不包含调试输出,而是只包含短错误(与$mail->ErrorInfo中存储的内容完全相同)。即使设置为$mail->SMTPDebug=4,也会发生这种情况;我想出来了。当出现错误时,回调函数不会被调用一次,而是被多次调用——每行调试信息调用一次。因此,您必须确保如上所述将$str变量连接到$GLOBALS['debug']变量(而不是像我那样分配变量),否则您只能得到最后一行调试信息。。。这通常与$mail->ErrorInfo相同。