title: Send form values through ajax to smtp mail form
body: <p>Email form not sending and can't figure out why. I used the advice form this post tp create the form. <a href="https://stackoverflow.com/questions/21357801/submit-form-and-a-textarea-on-ajax-post">Submit form and a textarea on ajax post</a></p>
  
  <p>the reason for doing this is to greate a IE8 and 9 friendly form that works.</p>
  
  <p>The on click function....</p>
  
  <pre><code>                $("form#example-advanced-form").click(function() {
                      //alert("submitting?");
                      // validate() just checks that required fields have values
                      //if (validate()) {
                          $.ajax({
                              type: 'POST',
                              url: 'PHPMailer/sendMyform.php',
                               data: { name: $('#name').val(),
                                       from: $('#email').val(),
                                       subject: $('#role').val(),
                                       message: $('#coverletter').val()
                              },// end data
                              success: function clearFields() {
                                  $('#name').val('');
                                  $('#email').val('');
                              } // end success
                          }); // end ajax
                      /*}
                      else
                      {
                          var errmsg = "Your email could not be sent.&lt;br /&gt;";
                          errmsg += "Please ensure that you've filled in all the fields.";
                          $(".errmsg").html(errmsg);
                          $(".errmsg").css("color", "#ff0000");
                      }*/
                      $('form#example-advanced-form').submit();
                  }); // end click
  </code></pre>
  
  <p>The send mail form receiving the data...</p>
  
  <pre><code>    error_reporting(E_ALL);
      require_once("class.phpmailer.php");
      include("class.smtp.php");
  
      $email = new PHPMailer();
  
      try
      {
          //
          // Set server details for send
          //
          $email-&gt;IsSMTP();
          $email-&gt;Host = "****";
          $email-&gt;Port = 25;
          $email-&gt;SMTPAuth = true;
          $email-&gt;Username = "****";
          $email-&gt;Password = "****";
  
  
  
          //
          // Send mail from the contact form
          //
          $to = "****";
          $from = $_POST["email"];
          $name = $_POST["name"];
          $subject = "From web: ".$_POST["role"];
          $message = $_POST["name"];
  
          $body = "&lt;p&gt;Hi,&lt;/p&gt;";
          $body .= "&lt;p&gt;You have received a new query on your website.&lt;/p&gt;&lt;p&gt;Please see below:&lt;/p&gt;";
          $body .= "&lt;p&gt;";
          $body .= str_replace("\r\n", "&lt;br /&gt;", $message);
          $body .= "&lt;/p&gt;";
          $body .= "&lt;/body&gt;&lt;/html&gt;";
  
          $email-&gt;SetFrom($from, $name);
          $email-&gt;AddReplyTo($from, $name);
          $email-&gt;AddAddress($to, $to);
          $email-&gt;Subject = $subject;
          $email-&gt;Body = $body;
          $email-&gt;IsHTML(true);
  
          $email-&gt;Send();
  
          session_start();
          $_SESSION["mailresult"] = "success";
          http_redirect("http://www.this.com");
      }
      catch (Exception $e)
      {
          $_SESSION["mailresult"] = "failed";
          $_SESSION["mailerror"] = $e-&gt;getMessage();
      }
  </code></pre>
  
  <p>I get a error Call to undefined function on line 49 which is...</p>
  
  <pre><code>            http_redirect("http://www.this.com");
  </code></pre>