problem with email form in html using php
Posted: Wed Aug 24, 2011 1:41 pm
Hey there
I wrote php codes for processing to send email but I feel bit hopeless because when you click on send button after filling a form, you got message like "thank you for contacting us". It is working but I still dont receive this email. I have tested it and send to my email when clicked send button but email didnt come through.
I wonder what is wrong?
Maybe you can check out my codes and tell me where is error? I would appreciate your help.
HTML MARKUP (contactformpage.html)
<form name="form1" method="post" action="contactformprocess.php">
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td><label for="email">
<div align="right">Email Address:</div>
</label>
</td>
<td><div align="left">
<input name="email" type="text" id="email" size="35" maxlength="100">
</div></td>
</tr>
<tr>
<td><label for="name">
<div align="right">Name:</div>
</label>
</td>
<td><div align="left">
<input name="name" type="text" id="name" size="35" maxlength="80">
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="comments">Comments:</label>
</div></td>
<td><div align="left">
<textarea name="comments" id="comments" cols="26" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="clear"></label>
<input type="reset" name="clear" id="clear" value="Reset Form">
</div></td>
<td><div align="right">
<label for="submit"></label>
<div align="left">
<input type="submit" name="submit" id="submit" value="Send Email!">
</div>
</div></td>
</tr>
</table>
</form>
PHP codes (contactformprocess.php)
<?php
$emailSubject = 'You got message from your website';
$webMaster = 'myname@lantic.net';
$email = $_POST['email'];
$name = $_POST['name'];
$comments = $_POST['comments'];
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Comments: $comments
EOD;
$headers = "Form:$email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
$theResults = <<<EOD
<html>
<head>
<title>Process</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>
<div>
<div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
I wrote php codes for processing to send email but I feel bit hopeless because when you click on send button after filling a form, you got message like "thank you for contacting us". It is working but I still dont receive this email. I have tested it and send to my email when clicked send button but email didnt come through.
I wonder what is wrong?
Maybe you can check out my codes and tell me where is error? I would appreciate your help.
HTML MARKUP (contactformpage.html)
<form name="form1" method="post" action="contactformprocess.php">
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td><label for="email">
<div align="right">Email Address:</div>
</label>
</td>
<td><div align="left">
<input name="email" type="text" id="email" size="35" maxlength="100">
</div></td>
</tr>
<tr>
<td><label for="name">
<div align="right">Name:</div>
</label>
</td>
<td><div align="left">
<input name="name" type="text" id="name" size="35" maxlength="80">
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="comments">Comments:</label>
</div></td>
<td><div align="left">
<textarea name="comments" id="comments" cols="26" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="clear"></label>
<input type="reset" name="clear" id="clear" value="Reset Form">
</div></td>
<td><div align="right">
<label for="submit"></label>
<div align="left">
<input type="submit" name="submit" id="submit" value="Send Email!">
</div>
</div></td>
</tr>
</table>
</form>
PHP codes (contactformprocess.php)
<?php
$emailSubject = 'You got message from your website';
$webMaster = 'myname@lantic.net';
$email = $_POST['email'];
$name = $_POST['name'];
$comments = $_POST['comments'];
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Comments: $comments
EOD;
$headers = "Form:$email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
$theResults = <<<EOD
<html>
<head>
<title>Process</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>
<div>
<div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>