Jump to content

Recommended Posts

Okay, so I discovered this part of the forum just now. I never used a library script before, but I decided to use the PEAR Mail package for the emails that are sent from my site. I tried running this code:

 

  if (isset($_POST['submit'])){
    require_once "mail/Mail.php";

     // Database works fine, so db code left out...

    if(mysql_query($sql,$db_link)){

      $from = "From <address>";
      $to = "To <address>";

      $host = "mail domain";
      $username = "username";
      $password = "password";
      $headers  = 'MIME-Version: 1.0' . "\r\n";
      $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

      $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, $message);

      if (PEAR::isError($mail)) {
        echo "<h3>The message was not sent...</h3>" . $mail->getMessage();
      }else{
        echo "<h3>The message was sent successfully...</h3>";
      }
    }
    mysql_close($db_link);
  }
?>

 

But then the script generates this error messages:

  Warning: main(PEAR.php) [function.main]: failed to create stream: No such file or directory in f:\wwwroot\<address>\mail\Mail.php on line 46

  Fatal error: main() [function.main]: Failed opening required 'PEAR.php' (include_path='.;c:\php4\pear') in f:\wwwroot\<address>\mail\Mail.php on line 46

 

What does this mean? Is it only because pear and mail is in different folders and I didn't include the PEAR.php in the contact page?

 

PEAR.php is at: \domain\pear\PEAR\

Mail.php is at: \domain\mail\

 

Or is there some kind of other configuration that I missed? I only uploaded Mail and PEAR base files via ftp, did nothing extra

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/201784-php-pear-mail-help/
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.