title: Simple Php Mailer.php and a contact.html, need html help might be missing few tags
body: <p>Hi im totally new to php, i have a website where i have a contact.html,it has forms where in name, email, insurance type, subject and comments can be filled. 
  Up on clicking submit button, the specfied email will recieve the details. Cant seem to locate the problem.</p>
  
  <p>here is the html code of contact.html</p>
  
  <pre><code> &lt;form id="ajax-contact-form"&gt;
          &lt;div class="row"&gt;
              &lt;div class="span4"&gt;
                  &lt;div class="form-padding"&gt;
                      &lt;label for="f1"&gt;Your name(required):&lt;/label&gt;
                      &lt;input type="text" name="name" id="f1" class="form-text" value=""/&gt;
                      &lt;label for="f2"&gt;Insurance type:&lt;/label&gt;
                      &lt;input type="text" name="category" id="f2" class="form-text" value="" size="40"/&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="span4"&gt;
                  &lt;div class="form-padding"&gt;
                      &lt;label for="f3"&gt;Your email(required):&lt;/label&gt;
                      &lt;input type="text" name="email" id="f3" class="form-text" value="" size="40"/&gt;
                      &lt;label for="f4"&gt;Subject:&lt;/label&gt;
                      &lt;input type="text" name="subject" id="f4" class="form-text" value="" size="40"/&gt;        
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;div class="span8"&gt;
                  &lt;div class="form-padding"&gt;
                      &lt;label for="f5"&gt;Message(required):&lt;/label&gt;
                      &lt;textarea name="message" id="f5" cols="40" rows="10"&gt;&lt;/textarea&gt;    
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
                      &lt;!-- send mail configuration --&gt;
                      &lt;input type="hidden" value="myemail@gmail.com" name="to" id="to" /&gt;
                      &lt;input type="hidden" value="myemail@gmail.com" name="from" id="from" /&gt;
                      &lt;input type="hidden" value="From contact form" name="subject" id="subject" /&gt;
                      &lt;input type="hidden" value="send-mail.php" name="sendMailUrl" id="sendMailUrl" /&gt;
                      &lt;!-- ENDS send mail configuration --&gt;               
                      &lt;p&gt;&lt;input type="button" class="button red small" value="Submit Form" name="submit" id="submit" /&gt;&lt;/p&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>AND MY SEND-MAIL.PHP</p>
  
  <pre><code>    &lt;?php
          //vars
          $subject = $_POST['subject'];
          $to = explode(',', $_POST['to'] );
  
          $from = $_POST['email'];
  
          //data
          $msg = "NAME: "  .$_POST['f1']    ."&lt;br&gt;\n";
          $msg .= "INSURANCE: "  .$_POST['f2']    ."&lt;br&gt;\n";
          $msg .= "EMAIL: "  .$_POST['f3']    ."&lt;br&gt;\n";
          $msg .= "SUBJECT: "  .$_POST['f4']    ."&lt;br&gt;\n";
          $msg .= "COMMENTS: "  .$_POST['f5']    ."&lt;br&gt;\n";
  
          //Headers
          $headers  = "MIME-Version: 1.0\r\n";
          $headers .= "Content-type: text/html; charset=UTF-8\r\n";
          $headers .= "From: &lt;".$from. "&gt;" ;
  
  
          //send for each mail
          foreach($to as $mail){
             mail($mail, $subject, $msg, $headers);
          }
  
          ?&gt;
  </code></pre>
  
  <p>My JS function</p>
  
  <pre><code>// contact form
  $("#ajax-contact-form").submit(function() {
  var str = $(this).serialize();
      $.ajax({
      type: "POST",
      url: "send-mail.php",
      data: str,
      success: function(msg) {
          if(msg == 1) {
              result = '&lt;div class="alert success fade in"&gt;Your message has been sent. Thank you!&lt;a href="#" class="close-alert" data-dismiss="alert"&gt;&lt;/a&gt;&lt;/div&gt;';
              $("#ajax-contact-form").hide();
          } else {result = msg;}
          $('#form-message').hide();
          $('#form-message').html(result);
          $('#form-message').fadeIn("slow");
          }
      });
  return false;
  });
  </code></pre>
  
  <p>My Questions</p>
  
  <ol>
  <li><p>There seems to be an error, cant send mails. Im a naive. Any help would be appreciated.</p></li>
  <li><p>How to do i show a success message after clicking submit button.</p></li>
  </ol>
  
  <p>Thanks</p>