I know that this is a question that has been answered lots and I've read a few of them, but I just can not seem to get my send mail function to work. So the basics are I have an HTML contact form:
<form id="contact" action="mail_handler.php" method="post">
<div class="col-md-6">
<fieldset>
<input name="name" type="text" class="form-control" id="name" placeholder="Your name..." required="">
</fieldset>
</div>
<div class="col-md-6">
<fieldset>
<input name="email" type="email" class="form-control" id="email" placeholder="Your email..." required="">
</fieldset>
</div>
<div class="col-md-12">
<fieldset>
<textarea name="message" rows="6" class="form-control" id="message" placeholder="Your message..." required></textarea>
</fieldset>
</div>
<div class="col-md-12">
<fieldset>
<button type="submit" value="Submit" class="btn">Send Message</button>
</fieldset>
</div>
</form>
This is attached an external file called mail_handler.php, this seems to be where I just can't get my file to work.
<?php
$email = $_POST["email"]; //users email
$name = $_POST["name"]; //users name
$msg = $_POST["message"]; //users message
$to = "email@mydomain.co.uk"; //my email
$subject = "New online enquiry"; //subject line
$headers = "From: $email \n"; //who is the email from
$message = "Name: $name \n sent the following enquiry: $msg"; //email content
$user = "$email";
$usersubject = "Thank You"; //subject for user email
$userheaders = "From: enquiries@samsonvilliers.co.uk \n"; //who email is from
$usermessage = "Thank you for sending a message, we will be in touch soon.";//thank you message to users email
mail($to,$subject,$message,$headers); //mail to me
mail($user,$usersubject,$usermessage,$userheaders); //mail to user
header('Location: send_mail.html'); //send to a new page with thank you message.
?>
I have tried altering the code in many different ways, but nothing seems to work, I am sure that I am making a very simple mistake, but any guidance would be very appreciated.