Greetings all.
Trying to use PEAR mail to mail some results of a quiz I have designed for students, when I get the following message:
"Warning:require_once(Mail.php)[function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\results.php on line 81"
followed by
"Fatal error:require_once(function.require]: Failed opening required 'Mail.php'(include_path='.;C:\xampp\php\PEAR')in C:\xampp\htdocs\results.php on line 81"
I know I have installed PEAR. I just think my path is wrong, but I am unsure how to fix it. Any ideas? In case there is something wrong with the code, here is the code:
<?php
error_reporting (E_ALL ^ E_NOTICE);
$title = "Quiz Results";
echo "<title>$title</title>";
if (isset ($_POST['submit'])) {
$name = $_POST['name'];
$q1 = "1.)" . $_POST['q1'];
$q2 = "2.)" . $_POST['q2'];
$q3 = "3.)" . $_POST['q3'];
$q4 = "4.)" . $_POST['q4'];
$q5 = "5.)" . $_POST['q5'];
$qp = "6.)" . $_POST['qp'];
}
if ($name == "") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q1 == "1.) ") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q2 == "2.) ") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q3 == "3.) ") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q4 == "4.) ") {
die ("You forgot something, go back and check over your quiz.");
}
if ($q5 == "4.) ") {
die ("You forgot something, go back and check over your quiz.");
}
{
echo<<<EOT
<p>Results: $name<br>
$q1<br>
$q2<br>
$q3<br>
$q4<br>
$q5</p>
EOT;
}
require_once "Mail.php";
$Name = $_POST['name'];
$from = "myname <myemail@myserver.com>";
$to = "meagain <anotheremail@anotherserver.com>";
$subject = "Quiz Results";
$Message = "Here are the quiz results. Correct answers were:
Question 1: Answer1,
Question 2: Answer2,
Question 3: Answer3,
Question 4: Answer4,
Question 5: Answer1,";
$align = $_POST['align'];
$body = "$Message\n\nQuiz By:
$Name\n$q1\n$q2\n$q3\n$q4\n$q5";
$host = "smpt.ofmine.com";
$port = "my port";
$username = "myusername@whatever.com";
$password = "mypassword";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smpt = Mail::factory('smpt',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smpt->send($to,$headers,$body);
if (PEAR::isError($mail)){
echo("<p>".$mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
header("Location: sent.php");
?>
Any help would be appreciated, thanks!