Create contact form and send mail in PHP

simple Contact us form create by HTML

<form action="test.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>
Send mail by php code –
<?php
$ToEmail = 'youremail@site.com';
$EmailSubject = 'Site contact form';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html";
$MESSAGE_BODY = "Name: ".$_POST["name"]."";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>

Leave a comment