I have an enquiry form where once the user click the submit button the form mailhandler.php and sends the email to myself.
I have tried doing this through php but its not fully working as I do not recieve any emails.
Here is my mail handler.php
<?php
if(isset($_POST['buttonSubmit'])){
$to = "xxxxxxx"; // my email has been hidden
$from = $_POST['emailInput']; // this is the sender's Email address
$first_name = $_POST['fNameInput'];
$last_name = $_POST['lNameInput'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['requestField'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['requestField'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
and my form
<form class = "form" name = "productEnquiry" id = "myForm" onsubmit="return validateForm();" action ="mailhandler.php" method = "post">
<div class = "FormImage">
<img src="images/productenquiry.html/enquiry2.jpg" id = "productEnquiryImage">
</div>
<div class = "form-element">
<label>Select category:</label>
<select id = "ddl1" onclick="valDDL1();" class = "input" onchange = "configDDL(this);">
<option value = "Default">Select product category</option>
<option value = "Salts">Salts</option>
<option value = "Fruits">Fruits</option>
<option value = "Cereals">Cereals</option>
<option value = "Meats">Meats</option>
<option value = "Drinks">Drinks</option>
<option value = "Other">Other</option>
</select><span class = 'error' id = "errorDDL1">*</span>
</div>
<br>
<div class = "form-element">
<label>Select product:</label>
<select id = "ddl2" onclick="valDDL2();" class = "input" class = "ddl">
<option></option>
</select><span class = 'error' id = "errorDDL2">*</span>
</div>
<br>
<div class = "form-element">
<label>First Name:</label>
<input type = "text" class = "input" name = "fNameInput" placeholder="John" onkeyup="valFirstName();" onchange="valFirstName();" id = "strFirstName"><span class='error' id="errorFirstName">*</span>
</div>
<br>
<div class = "form-element">
<label>Last Name:</label>
<input type = "text" class = "input" name = "lNameInput" placeholder = "Doe" onkeyup = "valLastName();" onchange = "valLastName();" id = "strLastName"><span class='error' id="errorLastName">*</span>
</div>
<br>
<div class = "form-element">
<label>Contact Phone Number:</label>
<input type = "text" class = "input" name = "phoneInput" placeholder = "123456789" onkeyup="valPhone();" onchange="valPhone();" id = "strPhone"><span class='error' id="errorPhone">*</span>
</div>
<br>
<div class = "form-element">
<label>Contact Email:</label>
<input type = "text" class = "input" name = "emailInput" placeholder = "example@example.com" onkeyup = "valEmail();" onchange = "valEmail();" id = "strContactEmail"><span class='error' id="errorContactEmail">*</span>
</div>
<br>
<div class = "form-element">
<label class = "enquiryLabel">Enquiry:</label>
<textarea rows = "16" cols = "50" placeholder = "enter your enquiry here" class = "input" id = "strEnquiry" name = "requestField" onkeyup = "valEnquiry();" onchange = "valEnquiry();"></textarea><span class='error' id="errorEnquiry">*</span>
</div>
<br>
How should we contact you?<span class='error' id="errorRadio"> *</span>
<br>
<br>
Phone:
<input type = "radio" name = "radioPhone" id = "radioPhone" onclick = "uncheck('radioEmail');">
<br>
Email:
<input type = "radio" name = "radioEmail" id = "radioEmail" onclick = "uncheck('radioPhone');">
<br>
<br>
<input type = "submit" class = "subresButtons" name = "buttonSubmit" id = "buttonSubmit" value = "Submit">
<input type = "reset" name = "subresButtons" id = "buttonReset" value = "Reset Form" onclick="window.location.reload();"><span class="errorHelp">(*) required fields</span>
</form>
Can anyone see why its not emailing me?
Cheers