Hello. I need your help with PHP.
I recently began studying it, and I am stuck at the "make a contact form" exercice.
I am trying to understand the concepts behind it. I think I get everything, but still my Form won't work.
I event went as far as to reproduce an example from the Internet, and it doesn't work either... I'm starting to think there is something wrong with my PHP installation.
Here is the HTML code for the form:
<html>
<body>
<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">Comment:</td>
<td><textarea name="comment" 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>
</body>
</html>
And here is the code for the php file (send_contact.php):
<?php
$ToEmail = 'my@email.com';
$EmailSubject = 'Site contact form ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
I'm getting this 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:\xampp\htdocs\send_contact.php on line 10
and then it says
Failure
whic means the code IS running to the end, but somehow it can't connect...
I'm using XAMMP for Apache.
Do I need to further tweak it?
Oh, and notice that I changed the code in $ToEmail to avoid posting my address on the internet, but I'm using my real address. It's gmail, by the way.
Thanks in advance