title: Contact form not sending an email
body: <p>Looks like everything should work properly. Where did I go wrong? 
  This is my first question on this resource so please do not judge strictly.</p>
  
  <p><strong>PHP</strong>:     </p>
  
  <pre><code>if(trim($_POST['p1']) == '') {    
  $hasError = true;
  } else {
  $name = trim ($_POST['p1']);
  }
  
  
  if(trim($_POST['p3']) == '') {
  $hasError = true;
  } else {
  if (function_exists ('stripslashes')) {
  $comments = stripslashes (trim($_POST ['p3']));
  } else {
  $comments = trim($_POST['p3']);
  }
  }    
  
  
  if(trim($_POST['p2']) == '')  {
  $hasError = true;
  } else if (!preg_match("/^([0-9_\.-]+)$/",
  trim($_POST['p2']))) {
  $hasError = true;} 
  else {
  $tel = trim($_POST['p2']);
  }
  //----------------------------------------
  
  if(trim($_POST['p4']) == '')  {
  $hasError = true;
  } else if (filter_var(trim($_POST['p4']), FILTER_VALIDATE_EMAIL)) {
  $email = trim($_POST['p4']);} 
  else {
  $hasError = true;
  }
  
  //----------------------------------------
  if(trim($_POST['p3']) == '') {
  $hasError = true;
  } else {
  if (function_exists ('stripslashes')) {
  $comments = stripslashes (trim($_POST ['p3']));
  } else {
  $comments = trim($_POST['p3']);
  }
  }
  
  if(!isset($hasError))
  $emailTo = 'donowan2@gmail.com';
  $body = "Name: $name \n\nTelephone: $tel\n Email: $email\n 
  \n\nComments:\n $comments";
  $Headers = 'From: My Site &lt;'.$emailTo.'&gt;' .
   "\r\n" . 'Reply-To: ' . $email;
   mail($emailTo,  $body, $Headers);
   $emailSent = true;
  
  
  
  if (isset($hasError)) {
  echo "&lt;script type=\"text/javascript\"&gt;";
  echo "window.alert (\"Пожалуйста, заполните все поля и введите коректные данные.\")";
  echo "&lt;/script&gt;";
  echo "&lt;script type=\"text/javascript\"&gt;";
  echo "window.location = \"/\"";
  echo "&lt;/script&gt;";
  }
  
  if($emailSent == true) {
  echo "&lt;script type=\"text/javascript\"&gt;";
  echo "window.alert(\"Письмо успешно отправлено\")";
  echo "&lt;/script&gt;";
  
  echo "&lt;p&gt;&lt;strong&gt;Письмо успешно отправлено&lt;/srtong&gt;&lt;/p&gt;";
  echo "&lt;p&gt;Спасибо Вам ";
  echo "за использование контактной формы. Ваше письмо успешно отправлено";
  echo "и мы вскоре свяжемся с Вами &lt;/p&gt;";
  }
  echo "&lt;a href = \"contacts.html\"&gt; Вернутся на страницу контактов &lt;/a&gt;";
  
  echo "&lt;script type=\"text/javascript\"&gt;";
  echo "window.location = \"/\"";
  echo "&lt;/script&gt;";
  
  ?&gt;
  </code></pre>
  
  <p><strong>HTML</strong>: </p>
  
  <pre><code> &lt;div style="float: right; width: 42%;"&gt;&lt;form novalidate="novalidate" id="contact-form"                       class="zakaz-forma" method="post" action="/sendmail.php" name=""&gt;
      &lt;div class="close"&gt;&lt;/div&gt;
      &lt;div class="contact-main"&gt;
                      &lt;div class="contact-field"&gt;
                          &lt;div class="contact-left"&gt;
                              &lt;p&gt;Efternamn:&lt;/p&gt;
                              &lt;p&gt;&lt;input type="text" placeholder="Efternamn:" aria-invalid="false" aria-required="true" class="forma2-name" size="40" value="" name="p1"&gt;&lt;/p&gt;
                              &lt;p&gt;Tel/mobil:&lt;/p&gt;
                              &lt;p&gt;&lt;input type="tel" placeholder="Tel/mobil:" aria-invalid="false" aria-required="true" class="forma2-mail" size="40" value="" name="p2"&gt; &lt;/p&gt;
                              &lt;p&gt;E-post:&lt;/p&gt;                          
                              &lt;p&gt;&lt;input type="email" placeholder="E-post:" aria-invalid="false" aria-required="true" class="forma2-mail" size="40" value="" name="p4"&gt; &lt;/p&gt;   
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;p&gt;
                      Frågor/Önskemål:&lt;br&gt;
                       &lt;textarea aria-invalid="false" class="forma2-message" rows="10" cols="40" name="p3"&gt;&lt;/textarea&gt; &lt;/p&gt;
                      &lt;a class="button-1" href="#" onclick="document.getElementById('contact-form').submit();"&gt;SKICKA&lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="wpcf7-response-output wpcf7-display-none"&gt;&lt;/div&gt;
          &lt;/form&gt;
  &lt;/div&gt;   
  </code></pre>
  
  <p>The function returns true, but the message does not come to an email. Thank you in advance.</p>