title: Server echoes warnings/errors that make a json expected response to be invalid
body: <p>I'm currently writing an ajax form with jquery.
  The form is handled with a PHP script then the information is sent via the PHPMailer lite class. (http://phpmailer.worxware.com/index.php)</p>
  
  <p>This is the PHP code:</p>
  
  <pre><code>    if ($mail-&gt;Send())
          echo '{"message":"Mensaje enviado con éxito","status":"ok"}';
      else
          echo '{"message":"Ocurió un error al envíar el mensaje, intentelo más tarde.","status":"fail"}';
  </code></pre>
  
  <p>I discovered this problem when the email submitted by the user is not a valid one, resulting in the following error:</p>
  
  <p><code>Invalid address: E-mail:Invalid address: E-mail:Could not execute: /usr/sbin/sendmail
  </code></p>
  
  <p>I should test the email. Ok. But the problem is that the previous error message "gets in the way" and corrupts the response. So I can solve the email error, but any other warning/error would corrupt the response.</p>
  
  <p>A 'corrupted' response example:</p>
  
  <blockquote>
    <p>Invalid address: E-mail:Invalid address: E-mail:Could not execute: /usr/sbin/sendmail 
    {"message":"Ocurió un error al envíar el mensaje, intentelo más tarde.","status":"fail"}</p>
  </blockquote>
  
  <p>(First line should not be there)</p>
  
  <p>And this is the javascript (jquery) part:</p>
  
  <pre><code>        $.ajax
      ({
          type: "POST",
          url: "contact.php",
          data: $(this).serialize(),
          success: function(data)
          {
              if(data.status == 'fail')
              {
                  do something with data.message;
              }
              else if(data.status == 'ok')
              {
                  do something else with data.message;
              }
          },
          dataType: 'json'
      });
  </code></pre>
  
  <p>Any help with this? :) thank you</p>