2

I am using Mochahost , I have have installed Mail from Pear. Now i don't know where it has installed the the files.

Kindly guide me where it has stored the installed files.

When i am using the following code its giving me the following error message.

      PHP Warning:  require(Mail.php): failed to open stream: 
No such file or directory in /home/

The error message is obvious, as i haven't added any file in my application folder.

The following is the code i am following.

Kindly guide me how to include the path of'Mail.php' file .

<?php

//require_once "Mail.php";
require "Mail.php";



$from = "Taha <abc@Hotmail.com>";


$to = "Taha <abc@Hotmail.com>";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";



$host = "111.11.11.111";

$username = "abc@Hotmail.com";

$password = "password";



$headers = array ('From' => $from,


  'To' => $to,

  'Subject' => $subject);



 $port = "2525";

 $smtp = Mail::factory('smtp',

  array ('host' => $host,

    'port' => $port,

    'auth' => true,

    'username' => $username,


    'password' => $password)); 

$mail = $smtp->send($to, $headers, $body);

echo "PEAR before";

if (PEAR::isError($mail)) {

  echo("<p>" . $mail->getMessage() . "</p>");


 } else {

  echo("<p>Message successfully sent!</p>");

 }
user2052394
  • 49
  • 1
  • 2
  • 10

4 Answers4

2

If you are using xampp go to shell given in the xampp control panel and enter the below command:

pear install -a Mail

This command works for me when i had the problem. I hope it also works for you :)

sticky bit
  • 36,626
  • 12
  • 31
  • 42
Koteshwar
  • 19
  • 3
1

Check if you have the pear directory in the include_path

php -r "echo get_include_path();"

if not you have to include it on your php.ini, or adding it directly on your code

<?php 
$path = '/usr/lib/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
Ebbe M. Pedersen
  • 7,250
  • 3
  • 27
  • 47
Charkan
  • 831
  • 6
  • 12
  • I have found the file in 'home/username/php/Mail.php' How can i include it from here? – user2052394 Jan 15 '15 at 11:48
  • I have found the file , Its stored here `home/username/php/Mail.php` now when i am including this file , its giving me following error message include '../../php/Mail/mail.php'; `PHP Warning: include(../../php/Mail/mail.php): failed to open stream` – user2052394 Jan 15 '15 at 11:49
  • how did you install the pear mail package? – Charkan Jan 15 '15 at 13:16
1

Thorough Working Solution:

This is because you are missing PEAR::Mail. While you have PEAR installed it does not guarantee PEAR::Mail. Plus that XAMPP has included a bad Tar.php

So please just follow this url instruction and it will work.

https://www.arclab.com/en/kb/php/xampp-windows-how-to-install-pear-mail-package-class.html

If you still have questions feel free to contact me. It was a pain for me until I found the above url.

Dung.

Dung
  • 19,199
  • 9
  • 59
  • 54
0

include it like :

<?php include 'home/username/php/Mail.php' ; ?>
Ali Malik
  • 1,331
  • 1
  • 10
  • 19
  • Waring is due to the fact that it is unable to find that path , check the path for that. – Ali Malik Jan 15 '15 at 11:55
  • Its still giving me the same error message.. ` failed to open stream: No such file or directory in /home` – user2052394 Jan 15 '15 at 12:09
  • just move this file to current working directory (from which you are calling this file include) for sake of testing and check if it solves the issue – Ali Malik Jan 15 '15 at 12:21
  • There is now a troubleshooting checklist for this frequent error here : https://stackoverflow.com/a/36577021/2873507 – Vic Seedoubleyew Apr 12 '16 at 15:31