I'm adding simple contact form to my website, but I don't receive emails when I submit it.
my html is:
<form action="contact.php" method="post" class="form-container">
<label for="name" class="form-title">Name</label>
<input id="name" class="form-field" type="text" name="cf_name" required>
<br/>
<label for="email" class="form-title">Email</label>
<input id="email" class="form-field" type="email" name="cf_email" required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$">
<br/>
<label for="message" class="form-title">Message</label>
<textarea id="message" class="form-field" name="cf_message" required></textarea>
<br/>
<div class="submit-container">
<input class="submit-button" type="submit" value="Send">
</div>
</form>
my php is:
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = 'info@littlerivermiami.com';
$subject = 'Message From: '.$field_name;
$body_message = 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'contact.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to info@littlerivermiami.com');
window.location = 'contact.html';
</script>
<?php
}
?>
I do see alert message that means the code works, but I don't receive email with filled in info from form.
any ideas why is it happening?
Aucun commentaire:
Enregistrer un commentaire