0

Possible Duplicate:
Failed to connect to mailserver at “localhost” port 25

I don't know what is wrong with my code, I think it should work but for some reason, when I view the php file on chrome and when I press 'submit' - it says "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:\xampp\htdocs\BumblebeeNursery\send_contact.php on line 27" The 'send_contact.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../../../Users/Ali/Documents/Dreamweaver/individual/style.css"   rel="stylesheet" type="text/css" />
</head>

<body>
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Message: $message <br> 
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";

$formcontent="From: $name \n Message: $message";
$recipient = "alisarraff5@hotmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader);
echo "Thank You!";
?>

?>
</body>
</html>

And the contact:

<form action="send_contact.php" method="POST"> 
<table width="400" border="0" cellspacing="2" cellpadding="0"> 
<tr> 
<td width="29%" class="bodytext">Your name:</td> 
<td width="71%"><input name="name" type="text" id="name" size="32"></td> 
</tr> 
<tr> 
<td class="bodytext">Email address:</td> 
<td><input name="email" type="text" id="email" size="32"></td> 
</tr> 
<tr> 
<td class="bodytext">Comments:</td> 
<td><textarea name="message" cols="45" rows="6" id="comment" class="bodytext">  </textarea></td> 
</tr> 
<tr> 
<td class="bodytext"> </td> 
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td> 
</tr> 
</table> 
</form>

Could somebody PLEASE help me, I am about to rip my hair off. Thank you in advance

Community
  • 1
  • 1
  • 4
    It can't find your mailserver. You need to check PHP's configuration. – andrewsi Jun 29 '12 at 21:22
  • 5
    PHP on windows **requires** you to configure the [`SMTP`](http://www.php.net/manual/en/mail.configuration.php#ini.smtp) option in php.ini before you are able to send mail. – DaveRandom Jun 29 '12 at 21:25
  • [How to send email from XAMPP (PHP)](http://expertester.wordpress.com/2010/07/07/how-to-send-email-from-xampp-php/) – Zoltan Toth Jun 29 '12 at 22:04
  • If you want to run a local mailserver, I would recommend hMailServer – Kris Jun 29 '12 at 23:04

1 Answers1

0

You cannot send emails from your localhost, rather you should be sending it through your real website on your domain server.

Community
  • 1
  • 1
FarrisFahad
  • 356
  • 1
  • 4
  • 17