php email and pear

Discussion in 'General' started by Check, Jul 2, 2007.

  1. Check

    Check New Member

    I used the perfect setup for ubuntu 6.06 and i see pear as a package being installed when you install php
    I need to email attachments via php and was doing some searching and have found that this is what most people are using.

    1a. Does it get installed with this how to? Or is this something else pear provides. aka i need to still install the mail portion of pear.

    1b. If it doesnt get installed, does anyone know of a how to on how to get it working with ispconfig?

    2. Is there another method that you guys recomend for this process or is pear the way to go here?

    Thanks for the advice
  2. Ben

    Ben ISPConfig Developer ISPConfig Developer

    Well either you build the functionality of sending E-Mails with attachments yourself (e.g. write an own class) or you take a pear package, which is imho much handier, especially when not thinking only about attachments but sending mails with additional plaintext beside html and stuff like this.

    Which commands pear provides you can see by just running
    pear help
    also pear list-upgrades or pear upgrade-all is quite helpfull to be up 2 date with your pear packages, while the list-upgrade is only necessary to see what's new.

    For sending mails I would use the Mail / Mime Class: /
    On those sites you find information on how to install / use these packages the rest is normal coder's doing ;)

    Normally this should work with ISPConfig (I mean ISPconfig's own apache+php are independent of this), but for at least the XLS Spreadsheetwriter I had to "patch" the config.lib.php of ISPConfig to add the peardirectory to the open_basedir directive when using safe mode. The additional http config field did not help here.
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    1a) The php-pear package is installed in the perfect setup guide. You should be able to use it out of the box in PHP scripts that are hosted on the main apache webserver (port 80).
  4. Check

    Check New Member

    Sorry to dig this back up, but i still cant get it to work.

    So now im not doing attachments, just want to use a seperate smtp server.

    Heres the code:
    require_once "Mail.php";
    $from = "Sandra Sender <[email protected]>";
    $to = "Ramona Recipient <[email protected]>";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    $host = "";
    $username = "myusername";
    $password = "mypassword";
    $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>");
    When i run that i get:
    Warning: require_once(Mail.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/web10/web/smileynotes/index.php on line 16
    Fatal error: require_once() [function.require]: Failed opening required 'Mail.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/web10/web/smileynotes/index.php on line 16
    Im not sure what you mean by "Main". This i dont think would be in the main since its on one of my sites managed by ispconfig.

    So how do i get ispconfig to also read the pear packages?
  5. Ben

    Ben ISPConfig Developer ISPConfig Developer

    Could you check at first, whether the Mail.php is locate in one of the mentioned include pathes or not, and if so, just for a test, when adding the absolute path in the require string, just to make sure that you are allowed to access this file, e.g. due to a open_basedir restriction...

Share This Page