title: PHPMailer 500 (Internal Server Error) jquery.js
body: <p>I have a form with AJAX,PHP. Sometimes when I want to send an email I get this error "500 Internal Server Error" I don't know what to do. Here is my code</p>
  
  <p>HTML:</p>
  
  <pre><code>            &lt;form id="myForm" method="post" class="result" &gt;
  
                  &lt;input class="input-style" type="email" required name="email" placeholder=" E-mail"&gt;&lt;br&gt;
                  &lt;br&gt;
                  &lt;input class="input-style" type="text" required name="subject" placeholder=" Subject"&gt;
                  &lt;br&gt;&lt;br/&gt;
                  &lt;textarea class="input-style" rows="5" required cols="100" name="message" placeholder=" Message"&gt;&lt;/textarea&gt;
                  &lt;input style="text-align:center;" id="sumbitBtn" class="submit-button" type="submit" name='submit-mail' value="SEND"&gt;   
              &lt;/form&gt;
  
  
  
          &lt;/div&gt;
      &lt;/div&gt;
  
  
  
  
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      $(document).ready(function ()
      {
          $(document).on('submit', '#myForm', function ()
          {
  
              //var fn = $("#fname").val();
              //var ln = $("#lname").val();
  
              //var data = 'fname='+fn+'&amp;lname='+ln;
  
              var data = $(this).serialize();
  
  
              $.ajax({
                  type: 'POST',
                  url: '../db/contact.php',
                  data: data,
                  success: function (data)
                  {
                      $("#myForm").fadeOut(500).hide(function ()
                      {
                          $(".result").fadeIn(500).show(function ()
                          {
                              $(".result").html(data);
                          });
                      });
  
                  }
              });
              return false;
          });
  
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my PHP part with PHPMailer</p>
  
  <pre><code>require '../plugins/phpmailer/PHPMailerAutoload.php';
  $email = $_POST['email'];
  $subiect = $_POST['subiect'];
  $body = $_POST['mesaj'];
  
  //var_dump($email);
  //var_dump($subiect);
  //var_dump($body);
  $mail = new PHPMailer(true);
  $mail-&gt;CharSet = "utf-8";
  $mail-&gt;IsSMTP();
  
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;Host = "myhost";
  $mail-&gt;Username = "email@ema.com";
  $mail-&gt;Password = "pass#";
  $mail-&gt;SMTPSecure = "tls";
  $mail-&gt;Port = "587";
  
  
  $mail-&gt;AddAddress('myemail', 'receivers');
  $mail-&gt;setFrom($email, $email);
  $mail-&gt;Subject = $subiect;
  $mail-&gt;IsHTML(true);
  $mail-&gt;Body = $body;
  
  if ($mail-&gt;Send()) {
  //    echo "Message was Successfully Send :)";
  }
  ?&gt;
  
  &lt;form id='myForm' class='result' &gt;
  
      &lt;input class='input-style' type='email' required name='email' placeholder=' E-mail'&gt;&lt;br&gt;
      &lt;br&gt;
      &lt;input class='input-style' type='text' required name='subject' placeholder=' Subject'&gt;
      &lt;br&gt;&lt;br/&gt;
      &lt;textarea class='input-style' rows='5' required cols='100' name='message' placeholder=' mess'&gt;&lt;/textarea&gt;
      &lt;!--    &lt;div id='icon-confirm'&gt;
              &lt;input style='text-align:center;' id='sumbitBtn' class='submit-button-sent' type='submit' name='submit-mail' value='SENT'&gt;
          &lt;/div&gt;--&gt;
  
      &lt;div class='input-group'&gt;
          &lt;span class='input-group-addon glyphicon glyphicon-ok icon-confirm' id='basic-addon1' style='color:#ffcc02 !important;background-color:transparent !important;'&gt;&lt;/span&gt;
          &lt;input type='button' class='form-control' value='Trimis' aria-describedby='basic-addon1'&gt;
      &lt;/div&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>I've tried to make change in code but no solution. What can I do to solve the problem? I think is from AJAX part</p>