Tuesday, January 30, 2018

php - send mail from form won't work

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:




























This is attached an external file called mail_handler.php, this seems to be where I just can't get my file to work.


    $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.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...