title: PHPMailer SMTP ERROR: Failed to connect to server
body: <pre><code>&lt;?php
  
  include("class.phpmailer.php");
  include("class.smtp.php");
  
  $mail = new PHPMailer();
  
  $mail-&gt;IsSMTP();  // telling the class to use SMTP
  $mail-&gt;Mailer = "smtp";
  $mail-&gt;SMTPDebug = 2;
  $mail-&gt;Host = "ssl://smtp.gmail.com"; // specify main and backup server
  $mail-&gt;Port = 587; // set the port to use
  $mail-&gt;SMTPAuth = true; // turn on SMTP authentication
  $mail-&gt;SMTPSecure = "tls";
  
  $mail-&gt;Username = "123@gmail.com"; // SMTP username
  $mail-&gt;Password = "password"; // SMTP password 
  
  $mail-&gt;From = "123@gmail.com";
  $mail-&gt;FromName = "Webmaster";
  
  $mail-&gt;AddAddress("asd@hotmail.com");
  $mail-&gt;AddReplyTo("123@gmail.com", "Webmaster");
  $mail-&gt;IsHTML(true);
  
  $mail-&gt;Subject  = "First PHPMailer Message";
  $mail-&gt;Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
  $mail-&gt;WordWrap = 50;
  
  if(!$mail-&gt;Send()) {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail-&gt;ErrorInfo;
  } else {
    echo 'Message has been sent.';
  }
  ?&gt;
  </code></pre>
  
  <p>It returns an error</p>
  
  <pre><code>2016-04-01 08:41:43 SMTP ERROR: Failed to connect to server: (0) 
  2016-04-01 08:41:43 SMTP connect() failed. 
  
  https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message was not sent.Mailer error: SMTP connect() failed. 
  
  https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
  </code></pre>
  
  <p>I am hosting this php on my xampp local server. The <code>extension=php_openssl.dll</code> on <code>php.ini</code> is already uncommended.</p>