Send errors message via email using error_log()

Luciano picture Luciano · Oct 13, 2010 · Viewed 8k times · Source

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>
...

Answer

wimvds picture wimvds · Oct 13, 2010

You should read the comments in the PHP reference for error_log, one of the first ones contains an example :

error_log("<html><h2>stuff</h2></html>",1,"[email protected]","subject  :lunch\nContent-Type: text/html; charset=ISO-8859-1");