Discussion in 'General' started by scotthawks, Jun 11, 2007.

  1. scotthawks

    scotthawks New Member

    I need a little help. i'm trying to use the mail function with pear, but i can't get it to work. PEAR is installed. i don't get any errors. any help is greatly appreciated.

  2. mccharlet

    mccharlet Member HowtoForge Supporter


    This is my procedure

    1. copy PEAR directory to /home/admispconfig/ispconfig
    2. change include_path = ".::/home/admispconfig/ispconfig/pear" to \root\ispconfig\php\php.ini

    I use this for use DB with squirrelmail

    Sorry for my english
  3. scotthawks

    scotthawks New Member

    thanks for the reply.

    i looked in the /root/admisoconfig/php/php.ini file and did not find a path that refered to pear. is my installation wrong or maybe not even installed??

  4. mccharlet

    mccharlet Member HowtoForge Supporter


    You can add this value ".::/home/admispconfig/ispconfig/pear" on the include_path variable.

    By default , she is blank
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Where do you want to use pear? If you want to use it in one of your websites, install the php pear package from your linux distribution. The installation mccharlet is only for the php that is used by the controlpanel itself and not the websites.
  6. Ben

    Ben ISPConfig Developer ISPConfig Developer

    I would never copy pear anywhere from the default dir, especially because when updating the pear packages.

    But you need to add the pear directory to the includepath in php.ini:
    beside that you have to "patch" /root/ispconfig/scripts/lib/config.lib.php
    about line 1427 beginning with
    and ending with
    Here change the openbasedir line to
    Where /usr/share/php has to be changed depending on your system. I use this without problems on two systems with debian sarge /etch. On centOS pear is afaik in /usr/share/pear.

    But remember to alway apply this fix whenever you update ispconfig.

    For me it is working fine and my cusomters can use the available pear packages I installed.
    The only thing what I am not happy with is that I have to set safemode to off in case of using HTML_AJAX :-\
  7. scotthawks

    scotthawks New Member

    still not working

    made the suggested changes and tried it, but still not working. here is the code i'm using.


    $recipients = '[email protected]';

    $headers['From'] = '[email protected]';
    $headers['To'] = '[email protected]';
    $headers['Subject'] = 'Test message';

    $body = 'Test message';

    $params['sendmail_path'] = '/usr/lib/sendmail';
    echo "hey";
    // Create the mail object using the Mail::factory method
    $mail_object =& Mail::factory('sendmail', $params);

    $mail_object->send($recipients, $headers, $body);


    the script fails when it tries to use the Mail.php file. for some reason, it's not loading it.
  8. Ben

    Ben ISPConfig Developer ISPConfig Developer

    I would use require_once / require instead of include.
    Because include only throws a warning, require stops with a critical error.

    So what is the exact errormessage you see when you try to include the mail.php?

    if you made my changes, did you restart the webserver and let ispconfig recreate the configs (e.g. when switching off and back on)?
    can you show the following data:

  9. scotthawks

    scotthawks New Member

    i did restart the server. here is the output from that code.

    string(30) "/usr/share/php/:/var/www/web2/" string(0) "" string(18) ".:/usr/share/pear/"
  10. Ben

    Ben ISPConfig Developer ISPConfig Developer

    in my opinion you should fill the safe_mode_include_dir with the path to pear. If you did already than you may be not allowed to read that value with ini_get().

    But what is the exact error message thta you get when you run your mailscript?
  11. scotthawks

    scotthawks New Member

    I don't get any message. just a blank screen. same thing with both require, require_once, and include. i will fill that var with the path to pear and see what happens.

  12. Ben

    Ben ISPConfig Developer ISPConfig Developer

    did you set "display_errors" to on in php.ini? If not the errors should loggd to a file (defined in php.ini as well).
    To make it easier you switch display_errors to on, you should be able to do that with ini_set directly in your script in case the server is productive...

    What is the errorlevel? E_ALL ~ E_NOTICE?
  13. scotthawks

    scotthawks New Member

    this reports all errors except notice.
  14. scotthawks

    scotthawks New Member

    Error Messages

    here are the error messages i get:

    Warning: require(Mail.php) [function.require]: failed to open stream: No such file or directory in /var/www/web2/web/php/sendmailtest.php on line 3

    Fatal error: require() [function.require]: Failed opening required 'Mail.php' (include_path='.:/usr/share/pear/') in /var/www/web2/web/php/sendmailtest.php on line 3

    looks to me like it's not seeing or able to open the Mail.php. i'm going to check permissions.
  15. scotthawks

    scotthawks New Member


    well, did some messing around and here is what i have.

    i moved all the pear php files to the directory that i was running the script from, and most errors went away. however, i now get this error when doing mail:

    Fatal error: Call to undefined method PEAR_Error::send() in /var/www/web2/web/php/simplemail.php on line 7

    i'm sure it has something to do with pear not being where it's supposed to be. still can't get it to read from /usr/share/pear like it's supposed too.

    any more ideas??
  16. Ben

    Ben ISPConfig Developer ISPConfig Developer

    well I only get this error, in case safe mode is on and safe_mode_include_dir is empty or not set to the pear path:

    As soon as I set the path its working fine:

    echo 'Safe Mode: '.ini_get('safe_mode');
    '<br>safe_mode_include_dir: '.ini_get('safe_mode_include_dir');
    '<br>include_path: '.ini_get('include_path');



  17. TauTau

    TauTau New Member

    I changed that open_basedir directive, but still phpinfo() shows only the sites root-dir in open_basedir. When I understand right, this is only included if !=suphp (where is suphp determined?), but I'm running suphp. Where should I change the open_basedir then? I've already set it in the alternative php.ini I'm using for that site, but it seems to get overwritten somewhere...

Share This Page