我在使用 wamp 的梨的发送邮件功能时遇到了一些麻烦。我完成了这个链接中的步骤:(http://pear.php.net/manual/en/installation.checking.php)检查我的梨是否安装正确,看起来我做对了。
<?php
require_once 'System.php';
var_dump(class_exists('System', false));
?>
上面的代码返回bool(true)
. 所以我假设我的路径设置正确。但是对于下面的代码,我遇到了错误。
<?php
include 'Mail.php';
include 'Mail/mime.php' ;
$text = 'Text version of email';
$html = '<html><body>HTML version of email</body></html>';
$file = 'test.xls';
$crlf = "\n";
$hdrs = array(
'From' => 'myemail@gmail.com',
'Subject' => 'Test mime message'
);
$mime = new Mail_mime(array('eol' => $crlf));
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file, 'text/plain');
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail');
$mail->send('myemail2@gmail.com', $hdrs, $body);
?>
错误在这一行:$mail =& Mail::factory('mail');
。Fatal error: Class 'Mail' not found
另外,我用这个命令安装了 pear Mail:pear install Mail Mail_mime
我将不胜感激任何帮助。
谢谢,