How can I check if PEAR is installed on my server or not?

I get an error, for example:

Warning: include_once (Net / SMTP.php) [function.include-once]: could not open the stream: there is no such file or directory in /usr/local/lib/php/Mail/smtp.php on line 348

Warning: include_once () [function.include]: Failed to open 'Net / SMTP.php' to enable (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 is:

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>");
 }
+5
source share
3 answers

if you have ssh access, you can log in and run

which pear

, -

/usr/bin/pear
+21

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

, . : http://pear.php.net/manual/en/installation.checking.php

+13

The following code may 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 .

+5
source

All Articles