使用error_log()通过电子邮件发送错误消息 [英] Send errors message via email using error_log()

查看:106
本文介绍了使用error_log()通过电子邮件发送错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

php函数error_log()允许您将日志发送到电子邮件,并将第二个参数设置为1.代码如下:

The php function error_log() let you send logs to email setting the second param to 1. I do that, but i want to dispay message in html. The code looks like this:

error_log($this->_errorMsg, 1, ADMIN_MAIL, "Content-Type: text/html; charset=utf8\r\nFrom: ".MAIL_ERR_FROM."\r\nTo: ".ADMIN_MAIL);

可能我弄乱了声明内容类型的内容,因为我以纯文本形式获取了味精:

Probably i mess something declaring the content type, because i get msg in plain text:

<h1>Website Error</h1>
<b>ERRNO:</b><font color='red'>1</font>
...

推荐答案

尝试像这样设置标题:

$headers = "From: someone@something.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

在末尾注意content-typemime标头.

这篇关于使用error_log()通过电子邮件发送错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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