【问题标题】:How Do I Check To See If PEAR Is Installed On My Server or Not?如何检查 PEAR 是否安装在我的服务器上?
【发布时间】:2011-07-16 15:17:10
【问题描述】:

我收到如下错误:

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

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

致命错误:在第 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>");
 }

【问题讨论】:

    标签: php email pear


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      使用此代码

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

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

      【讨论】:

      • 如果未安装模块,require_once 会以致命错误退出脚本。这就是为什么您应该首先检查模块是否已安装(请参阅上面的这个问题)。因此,这根本不是上述问题的答案。
      【解决方案3】:

      如果你有 ssh 访问权限,你可以登录并运行

      which pear
      

      如果已安装,它将打印类似这样的内容

      /usr/bin/pear
      

      【讨论】:

      • 这就是答案,选择它。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-19
      • 2014-07-16
      • 2013-09-26
      • 2014-03-13
      • 2013-12-06
      • 1970-01-01
      • 2015-12-24
      相关资源
      最近更新 更多