function log_to_errors($number, $message, $file, $line, $vars){
if(ENVIRONMENT !== 'development'):
ini_set('log_errors', 1);
ini_set('error_log', '../error_logs.txt');
$email = "
<div style='background: rgb(224, 224, 224); padding: 5px 10px;'>
<p>An error reference of ".$number." has occured on line: ".$line." in: <strong>".$file."</strong></p>
<p>".$message."</p>
<pre>".print_r($vars, 1)."</pre>
</div>
";
$email_header = 'Content-type: text/html; charset=iso-8859-1;';
error_log($email, 1, ADMIN_EMAIL, $email_header);
endif;
}
set_error_handler('log_to_errors');
我想修改这一行:
$email_header = 'Content-type: text/html; charset=iso-8859-1;'
这样我就可以设置其他电子邮件凭据的自定义信息,即电子邮件中的“来自和主题”元素,但是当我尝试执行以下操作时:
$email_header = 'From:errors@example.com; Content-type: text/html; charset=iso-8859-1;';
它打破了电子邮件中的html。 有人能指出我正确的方向,所以我可以为电子邮件设置一个消息主题等。
非常感谢, 路易斯
答案 0 :(得分:0)
您在dot (.)
之前错过$email_header
..
试试这个..
$email_header = 'Content-type: text/html; charset=iso-8859-1;'
$email_header .= 'From:errors@example.com; Content-type: text/html; charset=iso-8859-1;';
你不是concating
$email_header
字符串..
答案 1 :(得分:0)
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . chr(13) . chr(10);
$headers .= 'Content-type: text/html; charset=utf-8' . chr(13) . chr(10);
$headers .= 'Content-Transfer-Encoding: 8bit' . chr(13) . chr(10);
// Additional headers
$headers .= 'To: '. $to . chr(13) . chr(10);
$headers .= 'From: '. $from . chr(13) . chr(10);
$headers .= 'Reply-To: '. $clientmail . chr(13) . chr(10) . chr(13) . chr(10);