0

I installed Pear and then the Mail and SMTP components on my server. I then updated my php.ini file to "include_path = ".C:\wamp\bin\php\php5.4.3\pear" since that is where the Mail.php is. For some reason when I run this test script through a web browser I get the following errors.

Warning: require_once(Mail.php): failed to open stream: No such file or directory in C:\wamp\www\email.php on line 3

and:

Fatal error: require_once(): Failed opening required 'Mail.php' (include_path='.;C:\php\pear') in C:\wamp\www\email.php on line 3

I'm pretty new to PHP and before last week had never even heard of pear since I normally setup an exchange server. Any help would be appreciated. Below is the test Script.

<?php

 require_once "Mail.php";
 $from = "Ty Jacobs <FROM_EMAIL>";
 $to = "Ty Jacobs <TO_EMAIL>";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";

 $host = "ssl://smtp.bizmail.yahoo.com";
 $port = "465";
 $username = "MYUSERNAME";
 $password = "MYPASSWORD";

 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'port' => $port,
     '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>");
  }
 ?>

PHP.INI file:

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
include_path=".;C:\wamp\bin\php\php5.4.3\pear"
Ty Jacobs
  • 113
  • 2
  • 7
  • 23

2 Answers2

0

Did you restart your WAMP web server after making the change? Neglecting to restart the server after modifying php.ini is typically why you'll experience these sorts of issues, because the configuration changes are not read in until the web server is restarted.

Jason Gilmore
  • 3,698
  • 3
  • 23
  • 28
0
 (include_path='.;C:\php\pear')

According to this, your pear folder wasn't set up correctly in php.ini. Have you restarted your server?

By the way, you forgot a semicolon in the include path string. It should be:

.;C:\wamp\bin\php\php5.4.3\pear
ozahorulia
  • 9,798
  • 8
  • 48
  • 72
  • I did restart the services. I also have the semicolon in the pth in the php.ini. I have added it above so you can see exactly how I added to the .ini. – Ty Jacobs Jul 09 '13 at 18:26
  • Then, you're editing wrong php.ini file. Use `phpconfig()` to get the real php.ini file location. Also maybe there are more include_path definitions in the php.ini that could be the problem too. – ozahorulia Jul 09 '13 at 19:00
  • Hast, you were correct. This server has been up for 2 years with no changes made except to update Apache, MySQL, and PHP. I found 4 different PHP.INI files. Thanks you everyone for your help. – Ty Jacobs Jul 09 '13 at 21:42