Output phpmailer debugging to html variable

I want to use php mailers debugging information to display on a webpage. When I turn on debugging, it just repeats the line. This means that my html is out of order, so I want it to be displayed as a variable, so I can place the output html where I want.

$mail->SMTPDebug = 2; $mail->Debugoutput = 'html'; 
+6
source share
1 answer

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

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

Source: https://habr.com/ru/post/978668/


All Articles