Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpmailer debug output to html variable

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';
like image 395
glend Avatar asked Nov 25 '14 09:11

glend


1 Answers

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;
like image 146
Synchro Avatar answered Oct 23 '22 04:10

Synchro