title: How to print SMTP debug in other location?
body: <p>I'm trying to display the PHPMailer SMTP debug info. <strong>This is okay</strong> if the email failed but two emails are sent if success.</p>
  
  <pre><code>global $phpmailer;
  $send = wp_mail( $to, 'Test Email', $message );
  
  $phpmailer-&gt;SMTPDebug = 3;
  
  ob_start();
  $send = wp_mail( $to, 'Test Email', $message );
  $smtp_debug = ob_get_clean();
  
  
  echo "&lt;pre&gt;"; print_r( $smtp_debug ); echo "&lt;/pre&gt;";
  </code></pre>
  
  <p><strong>If I remove the first wp_mail()</strong>:</p>
  
  <pre><code>global $phpmailer;
  
  $phpmailer-&gt;SMTPDebug = 3;
  
  ob_start();
  $send = wp_mail( $to, 'Test Email', $message );
  $smtp_debug = ob_get_clean();
  
  
  echo "&lt;pre&gt;"; print_r( $smtp_debug ); echo "&lt;/pre&gt;";
  </code></pre>
  
  <p>It gives the warning:</p>
  
  <blockquote>
    <p>PHP Warning:  Creating default object from empty value in line:  <code>$phpmailer-&gt;SMTPDebug = 3;</code></p>
  </blockquote>
  
  <p><strong>If I remove the second wp_mail()</strong>, the <code>$smtp_debug</code> will be empty.</p>
  
  <p>So, how to only send one email on success and also grab the error on failure?</p>