I have a contact form that allows users to upload attachments. Its odd because when I use the contact form, the success message appears but when I check my email, I receive nothing either in my inbox or my spam folder. However, the files that I attach to the message DO appear in my /upload folder so that part seems to be working correctly.
It's just that I don't receive any message or anything. I'm not sure what's wrong. The code is pasted below.
<?
if($_SERVER['REQUEST_METHOD'] == "POST") {
$allowedExts = array("gif", "jpeg", "jpg", "png", "doc", "pdf", "docx", "jpg", "docx", "odt", "txt", "msg", "csv", "pps", "ppt", "pptx", "xml", "tar", "m4a", "mp3", "wav", "wma", "mp4", "mov", "flv", "exe");
for ($i = 1; $i <= 2; $i++) {
$temp = explode(".", $_FILES["attach".$i]["name"]);
$extension = end($temp);
if (in_array($extension, $allowedExts)) {
move_uploaded_file($_FILES["attach".$i]["tmp_name"],
"upload/" .$_POST["firstname"]."-".$_FILES["attach".$i]["name"]);
}
}
$to = 'myemail@gmail.ca';
$subject = 'Consultation from '.$_POST["firstname"];
$message = $_POST["message"]."\n\n\n Attachments: ".$_FILES["attach1"]["firstname"]." ".$_FILES["attach2"]["firstname"]." ".$_FILES["attach3"]["firstname"];
$firstname=$_REQUEST['firstname'];
$companyname=$_REQUEST['companyname'];
$email=$_REQUEST['email'];
if (($firstname=="")||($email=="")||($message==""))
{
echo "<strong><p class =greentip>A first name, message, and email are required, please fill <a href=/consult.php>the form</a> again.</p></strong><br>";
}
else{
mail($to, $subject, $message, $firstname, $email);
echo "<strong><p class = greentip>Your free consultation request has been received! Expect a detailed response within the next 3 hours.</p></strong>";
}
}
?>
<form action="" method="post" enctype="multipart/form- data">
<strong>First Name *</strong><br>
<input name="firstname" type="text" value=""><br>
<strong>Company Name </strong><br>
<input name="companyname" type="text" value=""><br>
<strong>Email *</strong><br>
<input name="email" type="text" value=""<br>
<strong>Your message *</strong><br>
<textarea name="message" rows="7" cols="30" placeholder="In your query, include any and all revelant information pertaining to the nature of your writing request. The more specific you are in your request, the more complete we will be in our response!"></textarea><br>
<strong>Attachments</strong><br>
<input name = "attach1" type="file" class="file" />
<br>
<input name = "attach2" type="file" class="file" />
<br><br>
<center><input type="submit" value="submit"></center> <br>
</form>