【发布时间】:2023-03-04 18:43:01
【问题描述】:
我在使用 wamp 的 pear 的发送邮件功能时遇到了一些问题。我完成了这个链接中的步骤:(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
我将不胜感激。
谢谢,
【问题讨论】:
-
你检查
include的返回值了吗?如果由于某种原因无法加载文件,它将返回布尔值 FALSE。 -
嘿,马克,当我做 var_dump(include 'Mail.php');它返回 int(1)。 Mail/mime.php 也一样。
-
它可能与 Zend Mail 类发生冲突吗?我问这个是因为如果我替换 include 'Mail.php';包括'C:/wamp/bin/php/php5.5.12/pear/Mail.php';然后运行脚本:- 我得到一个不同的错误:- 警告:mail():无法在“localhost”端口 25 连接到邮件服务器,验证 php.ini 中的“SMTP”和“smtp_port”设置或使用 ini_set( ) 在第 153 行的 C:\wamp\bin\p hp\php5.5.12\pear\Mail\mail.php 中。但是我的 smtp 设置又是正确的,我用简单的 php mail() 函数进行了测试。有什么想法吗?谢谢
标签: php email pear fatal-error classnotfound