bootstrap-contact-form-ajax


Topic: bootstrap-contact-form-ajax

Denny Feng asked 6 years ago

     <?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];
header('Content-Type: application/json');
if ($name === ''){
  print json_encode(array('message' => 'Name cannot be empty', 'code' => 0));
  exit();
}
if ($email === ''){
  print json_encode(array('message' => 'Email cannot be empty', 'code' => 0));
  exit();
} else {
  if (!filter_var($email, FILTER_VALIDATE_EMAIL)){
  print json_encode(array('message' => 'Email format invalid.', 'code' => 0));
  exit();
  }
}
if ($subject === ''){
  print json_encode(array('message' => 'Subject cannot be empty', 'code' => 0));
  exit();
}
if ($message === ''){
  print json_encode(array('message' => 'Message cannot be empty', 'code' => 0));
  exit();
}
$content="From: $name \nEmail: $email \nMessage: $message";
$recipient = "dfeng6@mail.ccsf.edu";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $content, $mailheader) or die("Error!");
print json_encode(array('message' => 'Email successfully sent!', 'code' => 1));
exit();
?>

I tried to send myself an email using the mail.php/index.php in the bootstrap-contact-form-ajax file and it says sent successfully but I cant receive it. I used multiple of emails, such as, Google, Yahoo and none received!


Arkadiusz Cacko staff pro premium priority answered 6 years ago

Hi,

I think the problem is that you don't have configured any mail server.

Please check this page it might be helpful.

Regards

Arek


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.6.1
  • Device: Computer
  • Browser: Google Chrome
  • OS: Computer
  • Provided sample code: No
  • Provided link: No
Related topics