2014-11-25 56 views
6

我希望使用php郵件程序調試信息顯示在網頁中。當我啓用調試它只是回聲的字符串。這意味着我的html無序,我希望爲此輸出作爲變量,以便我可以將輸出html放在我想要的位置。phpmailer調試輸出到html變量

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

回答

11

在PHPMailer的allows Debugoutput to be a closure最近的變化,所以你可以把它做任何你喜歡,例如收集所有的調試輸出,後來發出的:

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

優良,工作一種享受。謝謝。 – psycotik 2014-11-25 11:09:46

+1

這不是'''在'}'之後缺少一個';'嗎? – pgr 2017-11-03 20:22:33

+0

是的,修好了,謝謝。 – Synchro 2017-11-03 21:15:43