title: PHPMailer, SMTP Failed to connect to server
body: <p>I'm using PHPMailer.
  But when i upload to my host i get the error SMTP connect() failed.</p>
  
  <p>My environment
   1. Server OS:CentOS 7
   2. Web Services: XAMPP 5.6.8
   3. PHPMailer:5.2.4</p>
  
  <p>this is my code:</p>
  
  <pre><code>&lt;?php
      require_once('PHPMailer_old/class.phpmailer.php');
      try{
      $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
      $mail-&gt;IsSMTP(); // telling the class to use SMTP
      $mail-&gt;SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
      $mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication
      $mail-&gt;SMTPSecure = "ssl";
      $mail-&gt;SMTPAutoTLS = false;        // close TLS
      $mail-&gt;Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
      $mail-&gt;Port       = 465;                   // set the SMTP port for the GMAIL server
      $mail-&gt;Username   = "Test@gmail.com";  // GMAIL username
      $mail-&gt;Password   = "Test";  // GMAIpassword
  
      $mail-&gt;FromName = "Test Manager";
      $mail-&gt;From = "Test@gmail.com";
      $to = "Test@hotmail.com";
      $mail-&gt;AddAddress($to);
      $mail-&gt;Subject  = "First PHPMailer Message";
      $mail-&gt;AltBody    = "To view the message, please use an HTML compatible email viewer!";
      $mail-&gt;WordWrap   = 80;
      $body = "success!";
      $mail-&gt;MsgHTML($body);
      $mail-&gt;IsHTML(true);
      $mail-&gt;Send();
      echo "Message has been sent.";
      }catch(phpmailerException $e){
          echo "Sending Failed";
          echo $e -&gt; errorMessage();
      }
      ?&gt;
  </code></pre>
  
  <p>Error Message In web:
  SMTP -> ERROR: Failed to connect to server: (0) 
  Sending FailedSMTP Error: Could not connect to SMTP host.</p>