Topic: bootstrap-contact-form-ajax
Denny Feng free asked 5 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
Denny Feng free answered 5 years ago
I checked the spamm folder also but none received!
Bartłomiej Malanowski staff commented 5 years ago
Please check the answer of the colleague of mine here: https://mdbootstrap.com/support/jquery/bootstrap-contact-form-ajax/
Closed
This topic is closed.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Closed
- ForumUser: 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
Bartłomiej Malanowski staff commented 5 years ago
Do your messages comes to SPAM?