title: Contact form not sending [html, php, js]
body: <p>I'm trying to send e-mail using this contact form but i can't get it to work. It's outputing that is sent but i m not getting any. Tested sending mail with simple php form and i'm getting mail just fine so it's not server i presume.<br /><br />
  Any explanation highly appreciated.</p>
  
  <pre><code>&lt;form id="contact-form" action="email.php" method="post" class="clearfix"&gt;
                      &lt;div class="contact-box-hide"&gt;
                          &lt;div class="col-sm-6"&gt;
                              &lt;input type="text"  class="form-control" id="first_name" name="first_name" required placeholder="First Name"&gt;
                              &lt;span class="first-name-error"&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-6"&gt;
                              &lt;input type="text"  class="form-control" id="last_name" name="last_name" required placeholder="Last Name"&gt;
                              &lt;span class="last-name-error"&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-6"&gt;
                              &lt;input type="email" class="form-control"  id="contact_email" name="contact_email" required placeholder="Email Address"&gt;
                              &lt;span class="contact-email-error"&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-6"&gt;
                              &lt;input type="text"  class="form-control" id="subject" name="contact_subject" required placeholder="Subject"&gt;
                              &lt;span class="contact-subject-error"&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-10"&gt;
                              &lt;textarea class="form-control" rows="5" id="message" name="message" required placeholder="Message"&gt;&lt;/textarea&gt;
                              &lt;span class="contact-message-error"&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-2"&gt;
                              &lt;button id="contact-submit" class="btn custom-btn col-xs-12" type="submit" name="submit"&gt;&lt;a href=""&gt;&lt;/a&gt;&lt;i class="fa fa-rocket"&gt;&lt;/i&gt;&lt;/button&gt;
                              &lt;span id="contact-loading" class="btn custom-btn col-xs-12"&gt; &lt;i class="fa fa-refresh fa-spin"&gt;&lt;/i&gt; &lt;/span&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;&lt;!-- /.contact-box-hide --&gt;
                      &lt;div class="contact-message"&gt;&lt;/div&gt;
  
                  &lt;/form&gt;&lt;!-- /#contact-form --&gt;      
  </code></pre>
  
  <p>php</p>
  
  <pre><code>&lt;?php
  if($_REQUEST['first_name'] == '' || $_REQUEST['contact_email'] == '' ||        $_REQUEST['message'] == ''):
  return "error";
  endif;
  if (filter_var($_REQUEST['contact_email'], FILTER_VALIDATE_EMAIL)):
  $subject = 'Contact form'; // Subject of your email
  
  // Receiver email address
  $to = 'mail@domain.com';  //Change the email address by yours
  
  
  // prepare header
  $header = 'From: '. $_REQUEST['first_name'] . " " .$_REQUEST['last_name'] . '       &lt;'. $_REQUEST['contact_email'] .'&gt;'. "\r\n";
  $header .= 'Reply-To:  '. $_REQUEST['first_name'] . " "  .$_REQUEST['last_name'] . ' &lt;'. $_REQUEST['contact_email'] .'&gt;'. "\r\n";
  $header .= 'X-Mailer: PHP/' . phpversion();
  
  
  $message .= 'Name: ' . $_REQUEST['first_name'] . " " .$_REQUEST['last_name'] . "\n";
  $message .= 'Email: ' . $_REQUEST['contact_email'] . "\n";
  $message .= 'Subject: ' . $_REQUEST['contact_subject'] . "\n";
  $message .= 'Message: '. $_REQUEST['message'];
  
  // Send contact information
  $mail = mail( $to, $subject , $message, $header );
  
   echo 'sent';
  else:
   return "error";
  endif; 
  
  ?&gt;
  </code></pre>
  
  <p>js</p>
  
  <pre><code>$('#contact-submit').click(function () {
      $('.first-name-error, .last-name-error, .contact-email-error, .contact-subject-error, .contact-message-error').hide();
      var first_nameVal = $('input[name=first_name]').val();
      var last_nameVal = $('input[name=last_name]').val();
      var emailReg = /^(([^&lt;&gt;()[\]\\.,;:\s@\"]+(\.[^&lt;&gt;()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/igm;
      var emailVal = $('#contact_email').val();
      var contact_subjectVal = $('input[name=contact_subject]').val();
      var messageVal = $('textarea[name=message]').val();
  
      //validate
  
      if (first_nameVal == '' || first_nameVal == 'First Name *') {
          $('.first-name-error').html('&lt;i class="fa fa-exclamation"&gt;&lt;/i&gt; First name is required.').fadeIn();
          return false;
      }
      if (last_nameVal == '' || last_nameVal == 'Last Name *') {
          $('.last-name-error').html('&lt;i class="fa fa-exclamation"&gt;&lt;/i&gt; Last name is required.').fadeIn();
          return false;
      }
      if (emailVal == "" || emailVal == "Email Address *") {
  
          $('.contact-email-error').html('&lt;i class="fa fa-exclamation"&gt;&lt;/i&gt; Your email address is required.').fadeIn();
          return false;
  
      } else if (!emailReg.test(emailVal)) {
  
          $('.contact-email-error').html('&lt;i class="fa fa-exclamation"&gt;&lt;/i&gt; Invalid email address.').fadeIn();
          return false;
      }
       if (contact_subjectVal == '' || contact_subjectVal == 'Subject *') {
          $('.contact-subject-error').html('&lt;i class="fa fa-exclamation"&gt;&lt;/i&gt; Subject is required.').fadeIn();
          return false;
      }
      if (messageVal == '' || messageVal == 'Message *') {
          $('.contact-message-error').html('&lt;i class="fa fa-exclamation"&gt;&lt;/i&gt; Please provide a message.').fadeIn();
          return false;
      }
  
      var data_string = $('.contact-form').serialize();
  
      $('#contact-submit').hide();
      $('#contact-loading').fadeIn();
      $('.contact-error-field').fadeOut();
  
      $.ajax({
          type: "POST",
          url: "email.php",
          data: data_string,
  
          //success
          success: function (data) {
  
              $('.contact-box-hide').slideUp();
              $('.contact-message').html('&lt;i class="fa fa-check contact-success"&gt;&lt;/i&gt;&lt;div&gt;Your message has been sent.&lt;/div&gt;').fadeIn();
          },
          error: function (data) {
  
              $('.btn-contact-container').hide();
              $('.contact-message').html('&lt;i class="fa fa-exclamation contact-error"&gt;&lt;/i&gt;&lt;div&gt;Something went wrong, please try again later.&lt;/div&gt;').fadeIn();
          }
  
      }) //end ajax call
      return false;
  });
  </code></pre>