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

27,144

Solution 1

if you have ssh access, you can login and run

which pear

if it's installed it will print something like this

/usr/bin/pear

Solution 2

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

Solution 3

The following code might help if the server is on 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.

Share:
27,144
Navruk
Author by

Navruk

nothing to write

Updated on July 23, 2022

Comments

  • Navruk
    Navruk almost 2 years

    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

    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>");
     }
    
  • Matt Ryan
    Matt Ryan almost 12 years
    this is the answer, select it.
  • feeela
    feeela over 7 years
    require_once exits the script with a fatal error, if the module was not installed. This is why you should check first if the module is installed (see this question above). Thus this is not an answer to the question above at all.