检查是否安装了PEAR MAIL

时间:2017-01-14 12:48:07

标签: php pear

Pear已安装在我的服务器上。如何检查PEAR MAIL以及如何找到正确的PATH到梨!

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

谢谢!

2 个答案:

答案 0 :(得分:1)

我今天遇到了同样的问题,并设法得到了这个。

要检查已安装的软件包,请运行

pear list

以下是获取有关包裹信息的pear link

为了找到PEAR路径,PEAR的php_dir应该在PHP的包含路径中。如果没有,请将其添加到系统的php.ini中。

要在Web服务器中检查PHP的 include_path ,请创建仅包含phpinfo();的php文件,并将其作为check_php.php保存在本地Web根目录中。在浏览器中打开该文件,以验证您的Web服务器正在使用的include_path。

检查this pear link以获取有关验证包含路径的详细信息

答案 1 :(得分:0)

下面我将描述如何使用https://pear.php.net/manual/en/installation.checking.php中描述的步骤来实现它。

1)确认已安装PEAR。

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)这是PEAR安装.php文件的地方:

root@web [/opt/cpanel/ea-php70/root/usr/share/pear]# pear config-get php_dir
/opt/cpanel/ea-php70/root/usr/share/pear

3)这是PEAR安装.php文件的文件夹的内容:

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)我看到/opt/cpanel/ea-php70/root/usr/share/pear/Mail.php,其内容以以下几行开头:

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)在/home/website/public_html/stagingarea/app/webroot/testemail.php中,我创建了以下脚本:

<?php
    require_once "/opt/cpanel/ea-php70/root/usr/share/pear/Mail.php";
    $recipients = 'webmaster@jaimemontoya.com';
    $headers['From']    = 'webmaster@jaimemontoya.com';
    $headers['To']      = 'webmaster@jaimemontoya.com';
    $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)我访问了https://www.example.net/stagingarea/testemail.php,该脚本成功发送了电子邮件:

enter image description here