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();
?>

Hello, when I ran this code, I didn't receive anything in my emails, such as, Google, Yahoo, and etc, but this code works because i said sent successfully


Bartłomiej Malanowski staff pro premium commented 6 years ago

Do your messages comes to SPAM?


Denny Feng answered 6 years ago

I checked the spamm folder also but none received!


Bartłomiej Malanowski staff pro premium commented 6 years ago

Please check the answer of the colleague of mine here: https://mdbootstrap.com/support/jquery/bootstrap-contact-form-ajax/


FREE CONSULTATION

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

Status

Closed

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.6.0
  • Device: Desktop
  • Browser: Google Chrome
  • OS: Windows
  • Provided sample code: No
  • Provided link: No