I recently learned that I wasn't getting emails from my page contact form. It always worked before. So I have been trying different scripts that are out there including PHPEmailer and no cigar. I am including here the code for a very simple script.
<?php
$errors = '';
$myemail = 'lotusms@outlook.com';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address)) {
$errors .= "\n Error: Invalid email address";
}
if( empty($errors)) {
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n Email: $email_address \n Message \n $phone";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'index' page
header('Location: ../index.php');
}
?>
Of course it doesn't work either (or I wouldn't be here, would I?) ... :)
I tested the host with the following test file and I got a positive "Email Sent!" which means the server is responding.
<?php
mail('lotusms@outlook.com','Test mail','The mail function is working!');
echo 'Mail sent!';
?>
So, what is going on? Any ideas, or perhaps a code you are positive it will work?
p.s. The HTML is simple
<form id="search" method="POST" name="contactform" action="contact-form-handler.php">
.....
<a onclick="document.getElementById('search').submit()">
<button type="submit" class="btn btn-default" value="SEND"/>Get Quote
</a>
Thanks in advance