phpmailer调试输出到html变量 [英] phpmailer debug output to html variable

查看:203
本文介绍了phpmailer调试输出到html变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用php邮件调试信息显示在网页中.当我启用调试功能时,仅回显字符串.这意味着我的html乱了,我希望将其输出为变量,以便可以将输出的html放在我想要的位置.

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';

推荐答案

PHPMailer中的最新更改

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;

这篇关于phpmailer调试输出到html变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆