0

I have this contact form that won't send the email to me to let me know someone visited my site, where I'm I going wrong. Thanks. This is the test website in question.

<?php
function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}

$field_email = test_input($_POST['email']);
$field_name = test_input($_POST['name']);
$field_residence = test_input($_POST['residence']);
$field_profession = test_input($_POST['profession']);
$field_club = test_input($_POST['fave_club']);
$field_message = test_input($_POST['message']);


$mail_to = 'idwapro2@gmail.com';
$subject = 'Message from vidz.dundaah visitor '.$field_name;

$body_message = 'E-mail: '."\n".$field_email."\n\n";
$body_message .= 'Name: '."\n".$field_name."\n\n";
$body_message .= 'Residence: '."\n".$field_residence."\n\n";
$body_message .= 'Profession: '."\n".$field_profession."\n\n";
$body_message .= 'Fave_club: '."\n".$field_club."\n\n";
$body_message .= 'Message: '."\n".$field_message;

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'From: '.$field_name."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

header("Location:../contact.html"); 

?>
Max Njoroge
  • 489
  • 3
  • 21
  • please print/echo $mail_status and may be mail server is not install – suman das Jul 17 '16 at 11:09
  • You can use `error_get_last()`, when `mail()` returns false. `print_r(error_get_last())` – Quynh Nguyen Jul 17 '16 at 11:11
  • Comment redirect `header();`. `echo $mail_to, $subject, $body_message and $headers` and check all the values are appearing as expected. In the header one concatenation is missing. It should be `$headers .= 'From: '.$field_name."\r\n";` – Shrikant Mavlankar Jul 17 '16 at 11:11

0 Answers0