如何检查PEAR是否安装在我的服务器上?

时间:2021-11-09 20:59:12

I am getting error like:

我的错误是:

Warning: include_once(Net/SMTP.php) [function.include-once]: failed to open stream: No such file or directory in /usr/local/lib/php/Mail/smtp.php on line 348

警告:include_once(Net/SMTP.php)[功能。包含一次:未能打开流:在/ usr/local/lib/php/mail/smtp中没有这样的文件或目录。php在第348行

Warning: include_once() [function.include]: Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /usr/local/lib/php/Mail/smtp.php on line 348

警告:include_once()函数。包括:开放'Net/SMTP失败。php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /usr/ local/lib/php/mail/smtp .php在第348行

Fatal error: Class 'Net_SMTP' not found in /usr/local/lib/php/Mail/smtp.php on line 349

致命错误:类“Net_SMTP”在/usr/ local/lib/php/mail/smtp中没有找到php在第349行

My code:

我的代码:

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>");
 }

3 个解决方案

#1


21  

if you have ssh access, you can login and run

如果您有ssh访问,您可以登录并运行

which pear

if it's installed it will print something like this

如果安装了,它会打印出这样的东西

/usr/bin/pear

#2


13  

Use this code

使用这个代码

require_once 'System.php';
var_dump(class_exists('System'));

When this is true, pear is installed. More info: http://pear.php.net/manual/en/installation.checking.php

当这是真的时,就安装了pear。更多信息:http://pear.php.net/manual/en/installation.checking.php。

#3


5  

The following code might help if the server is on ubuntu.

如果服务器在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

More info here.

更多的信息在这里。

#1


21  

if you have ssh access, you can login and run

如果您有ssh访问,您可以登录并运行

which pear

if it's installed it will print something like this

如果安装了,它会打印出这样的东西

/usr/bin/pear

#2


13  

Use this code

使用这个代码

require_once 'System.php';
var_dump(class_exists('System'));

When this is true, pear is installed. More info: http://pear.php.net/manual/en/installation.checking.php

当这是真的时,就安装了pear。更多信息:http://pear.php.net/manual/en/installation.checking.php。

#3


5  

The following code might help if the server is on ubuntu.

如果服务器在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

More info here.

更多的信息在这里。