Reputation: 165
Pear is installed on my server. How to check PEAR MAIL is installed and how to find the right PATH to pear!
require_once 'System.php';
var_dump(class_exists('System'));
Thank you!
Upvotes: 2
Views: 4062
Reputation: 7701
I am describing below how I achieved it using the steps described at https://pear.php.net/manual/en/installation.checking.php.
1) Confirm that PEAR is installed.
root@web [/opt/cpanel/ea-php70/root/usr/share/pear]# pear version
PEAR Version: 1.10.7
PHP Version: 7.0.33
Zend Engine Version: 3.0.0
Running on: Linux web.example.net 2.6.32-754.27.1.el6.x86_64 #1 SMP Tue Jan 28 14:11:45 UTC 2020 x86_64
2) This is where PEAR installs .php
files:
root@web [/opt/cpanel/ea-php70/root/usr/share/pear]# pear config-get php_dir
/opt/cpanel/ea-php70/root/usr/share/pear
3) This is the content of the folder where PEAR installs .php
files:
root@web [/opt/cpanel/ea-php70/root/usr/share/pear]# ls -al
total 128
drwxr-xr-x 9 root root 4096 Mar 30 15:19 ./
drwxr-xr-x 9 root root 4096 Mar 11 10:17 ../
drwxr-xr-x 2 root root 4096 Mar 25 15:02 Archive/
drwxr-xr-x 2 root root 4096 Mar 25 15:02 Console/
drwxr-xr-x 2 root root 4096 Mar 30 15:19 Mail/
-rw-r--r-- 1 root root 9878 Mar 30 15:19 Mail.php
drwxr-xr-x 2 root root 4096 Mar 25 15:02 OS/
drwxr-xr-x 11 root root 4096 Mar 25 15:02 PEAR/
-rw-r--r-- 1 root root 15220 Mar 23 14:13 pearcmd.php
-rw-r--r-- 1 root root 35466 Mar 23 14:13 PEAR.php
-rw-r--r-- 1 root root 1069 Mar 23 14:13 peclcmd.php
drwxr-xr-x 3 root root 4096 Mar 25 15:02 Structures/
-rw-r--r-- 1 root root 20562 Mar 23 14:13 System.php
drwxr-xr-x 2 root root 4096 Mar 25 15:02 XML/
4) I see /opt/cpanel/ea-php70/root/usr/share/pear/Mail.php
, whose content starts with these lines:
root@web [/opt/cpanel/ea-php70/root/usr/share/pear]# cat Mail.php
<?php
/**
* PEAR's Mail:: interface.
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 1997-2017, Chuck Hagenbuch & Richard Heyes
* All rights reserved.
5) In /home/website/public_html/stagingarea/app/webroot/testemail.php
I created this script:
<?php
require_once "/opt/cpanel/ea-php70/root/usr/share/pear/Mail.php";
$recipients = '[email protected]';
$headers['From'] = '[email protected]';
$headers['To'] = '[email protected]';
$headers['Subject'] = 'Test message';
$body = 'Test message';
$params['sendmail_path'] = '/usr/lib/sendmail';
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('sendmail', $params);
$mail_object->send($recipients, $headers, $body);
?>
6) I visited https://www.example.net/stagingarea/testemail.php and that script sent the email successfully:
Upvotes: 0
Reputation: 43
I had the same problem today and managed to get this.
To check for installed packages, run
pear list
Here's the pear link for getting information about packages.
For finding the PEAR path, PEAR's php_dir should be in PHP's include path. If not, add it in your system's php.ini.
To check PHP's include_path in your web server, create a php file with only phpinfo();
as the contents, and save it in your local web root as check_php.php. Open the file in your browser, to verify the include_path your web server is using.
Check this pear link for more information about verifying the include path
Upvotes: 2