我收到的错误如下:
警告:include_once(Net / SMTP.php)[function.include-once]:无法打开流:第348行/usr/local/lib/php/Mail/smtp.php中没有此类文件或目录< / p>
警告:include_once()[function.include]:无法打开'Net / SMTP.php'以包含(include_path ='。:/ usr / lib / php:/ usr / local / lib / php')/第348行的usr / local / lib / php / Mail / smtp.php
致命错误:第349行的/usr/local/lib/php/Mail/smtp.php中找不到“Net_SMTP”类
我的代码:
require_once 'Mail.php';
$from = "me@example.com>";
$to = "you@gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "mail.example.com";
$username = "me";
$password = "test";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
答案 0 :(得分:23)
如果您有ssh访问权限,则可以登录并运行
which pear
如果已经安装,它将打印出类似这样的内容
/usr/bin/pear
答案 1 :(得分:13)
使用此代码
require_once 'System.php';
var_dump(class_exists('System'));
如果这是真的,安装梨。 更多信息:http://pear.php.net/manual/en/installation.checking.php
答案 2 :(得分:5)
如果服务器位于ubuntu上,以下代码可能会有所帮助。
sudo apt-get install php-pear
sudo pear install mail
sudo pear install Net_SMTP
sudo pear install Auth_SASL
sudo pear install mail_mime