I used the PHP contact form tutorial here on kirupa.com to make a contact form for my new website. When I click submit, I get the response that the message has been sent, but I don’t receive any email. When I first set up the script it was working fine, even after I added a couple of extra text fields. But now it won’t send me emails anymore…what’s wrong?
contact.html:
<form method="post" action="mailer.php">
<table width="400" height="120" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="67" height="30" valign="middle"><span class="text"><b>Name:</b></span> <br /></td>
<td width="333" height="30" valign="middle"><input type="text" name="name" size="30" class="brdr" /></td>
</tr>
<tr>
<td height="30" valign="middle"><span class="text"><b>E-Mail:</b></span></td>
<td height="30" valign="middle"><input type="text" name="email" size="30"class="brdr" /> </tr>
<tr>
<td height="30" valign="middle"><span class="text"><b>Phone:</b></span><br /></td>
<td height="30" valign="middle"><input type="text" name="phone" size="30" class="brdr" /></td>
</tr>
<tr>
<td width="67" height="30" valign="middle"><span class="text"><b>Website:</b></span><br /></td>
<td height="30" valign="middle"><input type="text" name="url" size="30" value="http://" class="brdr" /></td>
</tr>
</table>
<span class="text"><br /><br />
<b>What kind of project are you contacting us about?</b></span><br>
<select size="1" name="drop_down" class="brdr" >
<option>Please Select</option>
<option>Graphic Design</option>
<option>Web Design</option>
<option>Both</option>
<option>Other</option>
</select><br><br /><br />
<span class="text"><b>What is the best way to get in touch with you?</b></span><br>
<input type="checkbox" name="check[]" value="phone"> Phone<br>
<input type="checkbox" name="check[]" value="email"> Email<br><br><br>
<span class="text"><b>Message:</b></span><br>
<textarea rows="9" name="message" cols="48">
</textarea><br /><br />
<input type="submit" value="Submit" name="submit">
</form>
mailer.php:
<?php
if(isset($_POST['submit'])) {
$to = "petronella@mail.com";
$subject = "Inquiry from website";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$url_field = $_POST['url'];
$message = $_POST['message'];
$dropdown = $_POST['drop_down'];
foreach($_POST['check'] as $value) {
$check_msg .= "Contact by: $value
";
}
$body = "From: $name_field
E-Mail: $email_field
Phone: $phone_field
Website: $url_field
$check_msg Project: $dropdown
Message:
$message
";
echo "Thank you $name_field, your message has been sent. We look forward to speaking with you!";
mail($to, $subject, $body);
} else {
echo "We're sorry, the message can not be sent at the moment, we might be experiencing network problems. Please try later, or contact us at mail@mail.com. Thank you!";
}
?>