just a little help with this PHP email form, I have checked other questions on here but have found no solution yet.
I have a very simple PHP email subscribe form on my webpage, however it doesn't send the mail. Thought it could be a problem with my php.ini but that all seems to be good. Just wanted someone to look at the code on here and see if I'm being stupid or not!
<?php
$email_to = "subscribe@roomsby.com";
$success_message = "Thank you for subscribing to Roomsby.com. We will get back to you with details of our launch very soon!";
$site_name = "www.roomsby.com";
$email = trim($_POST['email']);
$submitted = $_POST['submitted'];
if(isset($submitted)){
if($email === '' || $email === 'Enter your email address' ) {
$email_empty = true;
$error = true;
} elseif (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/i", $email)){
$email_unvalid = true;
$error = true;
}
}
if(isset($error)){
echo '<span class="error_notice"><ul>';
if($email_empty){
echo '<li>Please enter your email address</li>';
} elseif ($email_unvalid) {
echo '<li>Please enter a valid email address</li>';
} else {
echo '<li>An error has occurred while sending your message. Please try again later.</li>';
}
echo "</ul></span>";
}
if(!isset($error)){
$subject = 'Newsletter Submission';
$body = "Email: $email";
$headers = 'From: ' . $site_name . ' <' . $emailTo . '> ' . "\r\n";
$headers .= 'Reply-To: ' . $email;
mail($email_to, $subject, $body, $headers);
echo '<span class="success_notice">' . $success_message . '</span>';
}
?>