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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5326475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 21:00:56  来源:igfitidea点击:

How Do I Check To See If PEAR Is Installed On My Server or Not?

phpemailpear

提问by Navruk

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

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

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

警告:include_once(Net/SMTP.php) [function.include-once]:无法打开流:第 348 行的 /usr/local/lib/php/Mail/smtp.php 中没有这样的文件或目录

警告:include_once() [function.include]:在 /usr/local 中打开“Net/SMTP.php”以包含 (include_path='.:/usr/lib/php:/usr/local/lib/php') 失败/lib/php/Mail/smtp.php 第 348 行

致命错误:在第 349 行的 /usr/local/lib/php/Mail/smtp.php 中找不到“Net_SMTP”类

My code:

我的代码:

require_once 'Mail.php';

$from = "[email protected]>";

$to = "[email protected]>";
$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>");
 }

回答by Matt Ryan

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

回答by turbod

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

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

回答by capjo

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.

更多信息在这里