phpmailer debug output to html variable

倖福魔咒の 提交于 2019-12-01 01:40:50

问题


Im looking to use php mailers debug information to display in a webpage. When I enable debugging it just echo's the string. This means that my html is out of order, I wish to therefor output as a variable so I can place the output html where i want it.

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

回答1:


A recent change in PHPMailer allows Debugoutput to be a closure, so you can make it do whatever you like, for example to collect all the debug output and emit it later:

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


来源:https://stackoverflow.com/questions/27122711/phpmailer-debug-output-to-html-variable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!