0

This is my first post so sorry if i stuff up the code block. I have been reading through the forum trying to figure out what is wrong but can't find an answer. I am hoping someone here can help. As the title suggests, when I click submit on my form I am getting to the "thank you for contacting us" message but the form isn't sending an email. I cannot for the life of me figure out why. Could someone please review my code and let me know if you find any errors. Would really appreciate your time.

<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email']))  {

//Email information
$admin_email = "tomcross@live.com";
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$comment = $_REQUEST['comment'];

//send email
mail($admin_email, "$subject", $comment, "From:" . $email);

//Email response
echo "Thank you for contacting us!";
}

//if "email" variable is not filled out, display the form
else  {
?>

   <form id="contact-form" class="contact" name="contact-form" method="post"          action="send-mail.php">
                    <div class="form-group">
                    <input type="text" name="name" class="form-control name-field" required placeholder="Your Name">
                    </div>
                    <div class="form-group">
                        <input type="email" name="email" class="form-control mail-field" required placeholder="Your Email">
                    </div> 
                    <div class="form-group">
                        <textarea name="message" id="message" required class="form-control" rows="8" placeholder="Message"></textarea>
                    </div> 
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">Send</button>
                    </div>
                </form> 

 <?php
  }
  ?>
  • Turn error reporting on, if not already active; and check for any error. – Ikari Aug 30 '16 at 00:59
  • What are you developing on, and does that server have a configured smtp? You may also do `$email = mail(...etc);` and then `var_dump($email)` though, that just let's you know if the email was dispatched to the smtp. – Perspective Aug 30 '16 at 01:04

0 Answers0