2011-03-16 17 views
5

estoy consiguiendo error como:¿Cómo puedo verificar para ver si PEAR está instalado en mi servidor o no?

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

Mi código:

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

Respuesta

19

si tiene acceso SSH, se puede iniciar o ejecutar

which pear 

si está instalado Será imprimir algo como este

/usr/bin/pear 
+4

esta es la respuesta, selecciónelo. –

13

Usar este código

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

Cuando esto es así, se instala pera. Más información: http://pear.php.net/manual/en/installation.checking.php

+1

'require_once' sale del script con un error fatal, si el módulo no se instaló. Es por eso que primero debe verificar si el módulo está instalado (vea esta pregunta más arriba). Por lo tanto, esta no es una respuesta a la pregunta anterior en absoluto. – feeela

5

El siguiente código podría ayudar si el servidor está en 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.

Cuestiones relacionadas