The “contact us” form that i’m using is not working. My website is hosted on hostinger. The MX records have been changed correctly. I contacted their support and everything is good on their end apparently. Hostinger’s platform even says there were 6 emails sent out (from me testing). The code seems to be working but supposedly the only issue can be due to the code. Been trying to fix this for hours and I have no clue what could be wrong.
It seems to all be sending correctly but I never receive anything in my email or spam folder.
Heres the PHP
<?php
$fname = trim($_POST['fname']);
$email = trim($_POST['email']);
$_message = trim($_POST['message']);
if ($fname == "") {
$msg['err'] = "\n First name can not be empty!";
$msg['field'] = "fname";
$msg['code'] = FALSE;
} else if ($email == "") {
$msg['err'] = "\n Email can not be empty!";
$msg['field'] = "Email";
$msg['field'] = "email";
$msg['code'] = FALSE;
} else if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
$msg['err'] = "\n Please put a valid email address!";
$msg['field'] = "email";
$msg['code'] = FALSE;
} else if ($_message == "") {
$msg['err'] = "\n Message can not be empty!";
$msg['field'] = "Message";
$msg['field'] = "message";
$msg['code'] = FALSE;
} else {
$to = '[email protected]';
$subject = 'Cynic Trendy - Contact Request';
$message = '<html><head></head><body>';
$message .= '<p>First Name: ' . $fname . '</p>';
$message .= '<p>Email: ' . $email . '</p>';
$message .= '<p>Message: ' . $_message . '</p>';
$message .= '</body></html>';
$headers = 'MIME-Version: 3.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$fname.' <'.$email.'>' . "\r\n";
$headers .= 'cc: [email protected]' . "\r\n";
$headers .= 'bcc: [email protected]' . "\r\n";
mail($to, $subject, $message, $headers);
$msg['success'] = "\n Email has been sent successfully.";
$msg['code'] = TRUE;
}
echo json_encode($msg);