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