MAIL FUNCTION
Posted: Thu Mar 16, 2006 2:09 pm
Pls Help! I was trying to create a application with the "mail()" function. The prgram gives an error on the mail() function. I have php v5 and according to the php.net webpage, the function should work but it dosen't. PLS HELP!
HERE IS THE CODE:
<form action="mail.php" method="post">
<input type="text" name="text">
<br />
<br />
<label>
<textarea name="textarea"></textarea>
<br />
</label>
<br />
<input type="submit" name="submit" value="Submit">
</form><br />
ERROR:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\Apache Group\Apache2\htdocs\mail.php on line 39
HERE IS THE CODE:
<form action="mail.php" method="post">
<input type="text" name="text">
<br />
<br />
<label>
<textarea name="textarea"></textarea>
<br />
</label>
<br />
<input type="submit" name="submit" value="Submit">
</form><br />
Code: Select all
$to = "trim9001@yahoo.com";
$subject = "Results from your Request Info form";
$headers = "From: My Site";
$forward = 0;
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\Apache Group\Apache2\htdocs\mail.php on line 39