title: PHP contact form does not send email
body: <p>We're having trouble getting our free estimate request form to function correctly. You can see our most current build here: <a href="http://tosa.atwebpages.com/free-estimate.html" rel="nofollow noreferrer">http://tosa.atwebpages.com/free-estimate.html</a></p>
  <p>We have wrapped all of our inputs in</p>
  <pre><code>&lt;form id=&quot;free-estimate&quot; method=&quot;post&quot; name=&quot;contact.php&quot; role=&quot;form&quot; class=&quot;needs-validation&quot; novalidate&gt;
  </code></pre>
  <p>Here is the code from our contact.php</p>
  <pre><code>&lt;?php
  /*
   *  CONFIGURE EVERYTHING HERE
   */
  
  // an email address that will be in the From field of the email.
  $from = 'donations.co@theothersideacademy.com';
  
  // an email address that will receive the email with the output of the form
  $sendTo = 'donations.co@theothersideacademy.com';
  
  // subject of the email
  $subject = 'New Moving and Storage Estimate Request';
  
  // form field names and their translations.
  // array variable name =&gt; Text to appear in the email
  $fields = array('name' =&gt; 'Name', 'surname' =&gt; 'Surname', 'need' =&gt; 'Need', 'email' =&gt; 'Email', 'message' =&gt; 'Message'); 
  
  // message that will be displayed when everything is OK :)
  $okMessage = 'Thank you for submitting your request! We will contact you soon.';
  
  // If something goes wrong, we will display this message.
  $errorMessage = 'There was an error while submitting the form. Please try again later';
  
  /*
   *  LET'S DO THE SENDING
   */
  
  // if you are not debugging and don't need error reporting, turn this off by error_reporting(0);
  error_reporting(E_ALL &amp; ~E_NOTICE);
  
  try
  {
  
      if(count($_POST) == 0) throw new \Exception('Form is empty');
              
      $emailText = &quot;You have a new request for moving and storage\n&quot;;
  
      foreach ($_POST as $key =&gt; $value) {
          // If the field exists in the $fields array, include it in the email 
          if (isset($fields[$key])) {
              $emailText .= &quot;$fields[$key]: $value\n&quot;;
          }
      }
  
      // All the neccessary headers for the email.
      $headers = array('Content-Type: text/plain; charset=&quot;UTF-8&quot;;',
          'From: ' . $from,
          'Reply-To: ' . $from,
          'Return-Path: ' . $from,
      );
      
      // Send email
      mail($sendTo, $subject, $emailText, implode(&quot;\n&quot;, $headers));
  
      $responseArray = array('type' =&gt; 'success', 'message' =&gt; $okMessage);
  }
  catch (\Exception $e)
  {
      $responseArray = array('type' =&gt; 'danger', 'message' =&gt; $errorMessage);
  }
  
  
  // if requested by AJAX request return JSON response
  if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
      $encoded = json_encode($responseArray);
  
      header('Content-Type: application/json');
  
      echo $encoded;
  }
  // else just display the message
  else {
      echo $responseArray['message'];
  }
  </code></pre>
  <p>The problem we are having is that we never receive an email once the form has been submitted. Everything appears to be working correctly as we don't see any errors in the console and we receive the success message ($okMessage)</p>
  <p>We have followed the tutorial from here: <a href="https://bootstrapious.com/p/how-to-build-a-working-bootstrap-contact-form" rel="nofollow noreferrer">https://bootstrapious.com/p/how-to-build-a-working-bootstrap-contact-form</a></p>
  <p>One thing I have noticed when testing the form is that when we submit, it validates the form with the green arrows, then shows our $okMessage  (&quot;Thank you for submitting your request! We will contact you soon.&quot;), but also shows that the (now) empty forms need to be filled out.
  <img src="https://i.stack.imgur.com/8Yf1O.png" alt="example" /></p>
  <p>We are using awardspace.com for our demo server if that is relevant.</p>