title: PHPMailer 5.2.0 sends out 2 mails each time
body: <p>First of all; sorry if this has been asnwered before, I have searched for the last couple of days with no luck.</p>
  
  <p>I am using PHPMailer 5.2.0 to send a mail from a form, which is called by an AJAX call from a jQuery script with <a href="http://malsup.com/jquery/form/" rel="nofollow">jQuery form</a>, each time I send the mail it sends it out twice. It must be that the script is called twice but I can't figure out where it happens.</p>
  
  <p>Here is the php script:</p>
  
  <pre><code>&lt;?php
  require_once('PHPMailer_5.2.0/class.phpmailer.php');
  //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  
  $navn= $_REQUEST['navn'];
  $tlf= $_REQUEST['tlf'];
  $ring= isset($_REQUEST['ring']) ? $_REQUEST['ring'] : 0;
  if($ring == 0)
  {
  $ring2 = " - og vil gerne ringes tilbage.";
  }
  else
  {
  $ring = "";
  }
  $email= $_REQUEST['email'];
  $sendToOwn= isset($_REQUEST['sendToOwn']) ? $_REQUEST['sendToOwn'] : 0;
  $besked= $_REQUEST['besked'];
  
  $mail             = new PHPMailer();
  
  //$body             = "testing 30/11";//file_get_contents('contents.html');
  //$body             = eregi_replace("[\]",'',$body);
  
  $mail-&gt;IsSMTP(); // telling the class to use SMTP
  $mail-&gt;Host       = "SMTP.Server.com"; // SMTP server
  $mail-&gt;SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                         // 1 = errors and messages
                                         // 2 = messages only
  
  $mail-&gt;SetFrom('noreply@sentfromDomain.dk', 'Name');
  
  $mail-&gt;ClearReplyTos("");
  $mail-&gt;AddReplyTo("mail@adress.com","Name");
  
  $mail-&gt;Subject = "Besked fra mjtransportogflyt.dk";
  $mail-&gt;MsgHTML("TEST FOR HELVEDE");//"&lt;p&gt;Denne mail er sendt af ".$navn." (".$email.") - ".$tlf.$ring2."&lt;/p&gt;&lt;p&gt;".$besked."&lt;/p&gt;");
  $mail-&gt;AltBody = "Denne mail er sendt af ".$navn." (".$email.") - ".$tlf.$ring2."&lt;br /&gt; ".$besked; // optional, comment out and test
  
  //$mail-&gt;MsgHTML($body);
  
  $address = "Sendto@thisadress.com";
  $mail-&gt;AddAddress($address, "Kasper John Doe");
  
  //$mail-&gt;AddAttachment("images/phpmailer.gif");      // attachment
  //$mail-&gt;AddAttachment("images/phpmailer_mini.gif"); // attachment
  
  if(!$mail-&gt;Send()) {
      echo "Mailer Error: " . $mail-&gt;ErrorInfo;
  } else {
      echo "Message sent!";
  }
  ?&gt;
  </code></pre>
  
  <p>And here is the jQuery:</p>
  
  <pre><code>$(document).ready(function(){
      function validate(formData, jqForm, options) { 
          for (var i=0; i &lt; formData.length; i++) { 
              if (!formData[i].value) { 
                  $('#results').removeClass('info').addClass('error');
                  $('#results').html('&lt;p&gt;&lt;strong&gt;Udfyld venligst alle felter&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Din besked blev &lt;strong&gt;ikke&lt;/strong&gt; sendt&lt;/p&gt;'); 
                  //Test om det bliver kaldt
                  //alert('works?');
                  return false; 
              } 
          }
          var options = {
              //target: '#results',
              success: showResponse
          };
          function showResponse(statusText){
              $('#results').removeClass('info').addClass('success');
              $('#results').html('&lt;strong&gt;&lt;p&gt;Beskeden er sendt!&lt;/p&gt;&lt;/strong&gt;');
              //Får tilbagemelding fra processed.php
              //alert(statusText);
          }
              $('#myform').ajaxSubmit(options);
          }
      $('#myform').ajaxForm({beforeSubmit:validate})
  
  });
  </code></pre>
  
  <p>And last heres the form:</p>
  
  <pre><code>&lt;form id="myform" method="post" action="processed.php"&gt;
      Lots and lots of inputs and stuff
      &lt;!--submit button below--&gt;
      &lt;button class="btn action"&gt;Send besked&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>