title: How to test whether SMTP connection credentials are correct without sending email in WordPress
body: <p>I have configured the PHP mailer settings in WordPress in the following way. How can I verify if the STMP credentials that I set are correct or not without sending any email using <code>wp_mail()</code>?</p>
  <pre><code>add_action('phpmailer_init', 'wpse8170_phpmailer_init');
  
  function wpse8170_phpmailer_init(PHPMailer $phpmailer)
  {
      $phpmailer-&gt;Host = 'your.smtp.server.here';
      $phpmailer-&gt;Port = 25; // could be different
      $phpmailer-&gt;Username = 'your_username@example.com'; // if required
      $phpmailer-&gt;Password = 'yourpassword'; // if required
      $phpmailer-&gt;SMTPAuth = true; // if required
      // $phpmailer-&gt;SMTPSecure = 'ssl';
      // enable if required, 'tls' is another possible value
  
      $phpmailer-&gt;IsSMTP();
  }
  </code></pre>