1
votes

I am kinda new to PHP, so I now have started using Pear where I want to use PHPUnit and other stuff.

I've encountered some errors, I've been looking through the internet to solve it, what I've figured out is that many people had this same problem, but had different sollutions to fix it. I want to sent a message through PHP and get the result to see if it had been successfully sent, I've been looking through the tutorial: http://www.youtube.com/watch?v=UH90nGNXab0

this is the code:

    <?php
require_once "Mail.php";
$from = "[email protected]";
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "ssl://smtp.gmail.com";//"smtp.gmail.com";
$port = "465";//"587";
$username = "picnicrus.ahmadhammad";
$password = "1234432112344321";
$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>");
}
?>

I keep getting this warning: require_once(Mail.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\MailSender\MailSender.php on line 2

following by this fatal error: require_once() [function.require]: Failed opening required 'Mail.php' (include_path='.;C:\wamp\bin\php\php5.3.10\pear') in C:\wamp\www\MailSender\MailSender.php on line 2

So, my conclussion is that:

1) The include path in my php.ini in php isnt correct (include_path = ".;C:\wamp\bin\php\php5.3.10\pear") also my include_path in php.ini in apache is (include_path = ".;C:\wamp\bin\php\php5.3.10\pear") So I wonder if it might be wrong?

2) Or the package isnt correct installed, I have downloaded "Mail" with the following files: mail.php, mime.php, mimePart.php, mock.php, null.php, RFC822.php, sendmail.php, smtp.php, smtpmx.php.

And that directory is in "C:\wamp\bin\php\php5.3.10\pear".

Regards Alexein

1
might be wrong time of the day to post ._.Alexein
As you are running on windows, I am not sure that it will make any difference to your immediate problem, but you should always ensure that you treat filenames in a case sensitive manner else you will always get problems running on anything other than windows. You say you have mail.php but are including Mail.php this definitely would not work on a Linux system you would need to include mail.php (lowercase) in order for it to work.Anigel
@Anigel: well now i tried to change in the require_once.. I changed to C:\wamp\bin\php\php5.3.10\pear\Mail\mail.php Where mail.php is the actual php-file And got: Fatal error: Class 'Mail' not found in C:\wamp\bin\php\php5.3.10\pear\Mail\mail.phpAlexein
When I just did a pear install of that package on my system (linux) there was a Mail.php in the folder above mail.php see if you have that file and if so put the full path to that file in your require as it does sound like your include path could be wrongAnigel

1 Answers

2
votes

Have you installed the Mail package? It sounded like you manually downloaded the files. If you have not installed the package, run the following command from a command prompt:

pear install Mail

That should put the Mail package into the correct pear library folder which should already be in your include_path.