0

I've got a pretty simple (I think) contact form - everything validates, but I receive no mail. Here's the php:

<?php
// Check for empty fields
if(empty($_POST['name'])        ||
  empty($_POST['email'])        ||
  empty($_POST['phone'])        ||
  empty($_POST['message'])  ||
  !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
  {
  echo "No arguments Provided!";
  return false;
  }

$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];

// Create the email and send the message
$to = 'youremail@email.com'; // I've replaced youremail with my proper email here
$email_subject = "Website Contact Form:  $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail:        $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: Lloyd\n";
$headers .= "Reply-To: $email_address"; 
mail($to,$email_subject,$email_body,$headers);
return true;            
?>

And here's the CSS:

     <div class="row contact-wrap"> 
            <form name="sentMessage" id="contactForm" novalidate>
                    <div class="row control-group">
                        <div class="form-group col-xs-6 floating-label-form-group controls">
                            <label>Name *</label>
                            <input type="text" class="form-control" placeholder="Name" id="name" required data-validation-required-message="Please enter your name.">
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>

                    <div class="row control-group">
                        <div class="form-group col-xs-6 floating-label-form-group controls">
                            <label>Email Address *</label>
                            <input type="email" class="form-control" placeholder="Email Address" id="email" required data-validation-required-message="Please enter your email address.">
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>

                    <div class="row control-group">
                        <div class="form-group col-xs-6 floating-label-form-group controls">
                            <label>Phone Number</label>
                            <input type="number" class="form-control" placeholder="Phone Number" id="phone">
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>

                    <div class="row control-group">
                        <div class="form-group col-xs-6 floating-label-form-group controls">
                            <label>Message *</label>
                            <textarea rows="5" class="form-control" placeholder="Message" id="message" required data-validation-required-message="Please enter a message."></textarea>
                            <p class="help-block text-danger"></p>
                        </div>
                    </div>

                    <br>
                    <div id="success"></div>
                        <div class="row">
                            <div class="form-group col-xs-12">

                                <p><em>* Required fields</em></p>

                                    <button type="submit" class="btn btn-success btn-lg">Sumbit</button>
                            </div>
                        </div>
                </form>


        </div>

I've got my proper scripts placed at the bottom and CSS is linked to in the header. I'm pretty new to contact forms so I'm not exactly surprised this isn't working, but I've used this on a different site and it works just fine.

John Conde
  • 217,595
  • 99
  • 455
  • 496
Lloyd
  • 43
  • 7
  • 2
    `$headers = "From: Lloyd\n";` that's the reason why. If that's what you're actually using. Probably being rejected or thrown into Spam. Plus, your form's method and missing special attributes. Special = name. – Funk Forty Niner Feb 10 '15 at 15:15
  • *"And here's the CSS:"* - That's not CSS, that's HTML. – Funk Forty Niner Feb 10 '15 at 15:17
  • Yea I know that's HTML, I was typing too fast. But the `$headers = "From: Lloyd\n";` you point out doesn't makes sense because it works on a different site with that same header. I've checked the Spam folder as well. – Lloyd Feb 11 '15 at 15:30

0 Answers0