2010-10-13 65 views
1

php函數error_log()讓你發送日誌到電子郵件設置第二個參數爲1.我這樣做,但我想在HTML中顯示消息。代碼如下所示:通過電子郵件發送錯誤消息使用error_log()

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

可能是我惹什麼聲明內容類型,因爲我得到的純文本信息:

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

我只是拍攝您的郵箱頁面的多種要求一個錯誤之後。你不想這樣做。 – 2010-10-13 17:04:35

+0

@Pekka:是的,我正在談論本土的。它不是一個框架,我正在一個獨立的登錄類上工作。 – Luciano 2010-10-13 17:07:53

+0

啊,你知道些什麼,那裏確實是[一個](http://de2.php.net/manual/en/function.error-log.php)。對不起,沒有意識到這個 – 2010-10-13 17:09:37

回答

3

嘗試設置你的頭,像這樣:

$headers = "From: [email protected]\r\n"; 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 

注意content-typemime結尾處的標題。

+1

thanx!現在完美地工作。 – Luciano 2010-10-13 17:26:43

3

你應該閱讀的PHP參考意見爲error_log,首當其衝的一個包含一個例子:

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