0
我已經安裝了PEAR郵件和Mail_Mime的最新版本,我嘗試發送測試消息,使用下面的測試電子郵件從this page,即錯誤消息
<?
include('/home/****/php/Mail.php');
include('/home/****/php/Mail/mime.php');
// Constructing the email
$sender = "**** <[email protected]****.com>"; // Your name and email address
$recipient = "**** <****@gmail.com>"; // The Recipients name and email address
$subject = "Test Email"; // Subject for the email
$text = 'This is a text message.'; // Text version of the email
$html = '<html><body><p>This is a html message</p></body></html>'; // HTML version of the email
$crlf = "\n";
$headers = array(
'From' => $sender,
'Return-Path' => $sender,
'Subject' => $subject
);
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$body = $mime->get();
$headers = $mime->headers($headers);
// Sending the email
$mail =& Mail::factory('mail');
$mail->send($recipient, $headers, $body);
?>
並且消息沒有被髮送。檢查我的錯誤日誌出現了:
[24-Jul-2012 02:14:50] PHP Fatal error: Call to undefined method Mail_mimePart::encodeHeader() in /home/**/php/Mail/mime.php on line 1330
我不知道是否有人知道這個錯誤消息與什麼有關和可以做些什麼呢?在mime.php 1330線在此功能的4號線:
function encodeHeader($name, $value, $charset, $encoding)
{
$mime_part = new Mail_mimePart;
return $mime_part->encodeHeader(
$name, $value, $charset, $encoding, $this->_build_params['eol']
);
}
不應被靜態調用。你確定這是正確的文件,有一個「返回Mail_mimePart :: encodeHeader(」但這不是你顯示的版本。 – 2012-07-24 02:41:22
你是怎麼安裝Mail和Mail_mime的?你應該可以使用:'include_once(「Mail/「;」調用它。「梨安裝郵件」和「梨安裝Mail_mime」應該是你如何安裝它們。 – David 2012-07-24 02:45:05
它們使用cPanel安裝。 – Nick 2012-07-24 02:47:04