title: phpmailer not working after migration to php 7
body: <p>Below is my php code </p>
  
  <p>Previously the server was on php 5.9 and we recently updated it to php 7.0</p>
  
  <p>while sending mail we get below error it says SMTP error but the credentials are correct</p>
  
  <p>Message could not be sent.
  Mailer Error: SMTP connect() failed. <a href="https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting" rel="nofollow noreferrer">https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting</a> </p>
  
  <pre><code>&lt;?php
  $cname = $_REQUEST[ 'cname' ];
  //echo $cname;
  $email = $_REQUEST[ 'email' ];
  //echo $email.',';
  $phone = $_REQUEST[ 'phone' ];
  //echo $phone.',';
  $datetime = $_REQUEST[ 'datetime' ];
  //echo $datetime.',';
  $package = $_REQUEST[ 'packages' ];
  //echo $package.',';
  
  
  $message = '&lt;table style="height: 231px; width: 490px; float: left;"&gt;
  &lt;tbody&gt;
  &lt;tr style="height: 21.5px;"&gt;
  &lt;td style="width: 235.433px; height: 21.5px;"&gt;&lt;strong&gt;Name:-&lt;/strong&gt;&lt;/td&gt;
  &lt;td style="width: 253.567px; height: 21.5px;"&gt;' . $cname . '&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr style="height: 21px;"&gt;
  &lt;td style="width: 235.433px; height: 21px;"&gt;&lt;strong&gt;Email:-&lt;/strong&gt;&lt;/td&gt;
  &lt;td style="width: 253.567px; height: 21px;"&gt;' . $email . '&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr style="height: 21px;"&gt;
  &lt;td style="width: 235.433px; height: 21px;"&gt;&lt;strong&gt;Phone No:-&lt;/strong&gt;&lt;/td&gt;
  &lt;td style="width: 253.567px; height: 21px;"&gt;' . $phone . '&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr style="height: 21px;"&gt;
  &lt;td style="width: 235.433px; height: 21px;"&gt;&lt;strong&gt;Date &amp; Time:-&lt;/strong&gt;&lt;/td&gt;
  &lt;td style="width: 253.567px; height: 21px;"&gt;' . $datetime . '&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr style="height: 21.5px;"&gt;
  &lt;td style="width: 235.433px; height: 21.5px;"&gt;&lt;strong&gt;Packages:-&lt;/strong&gt;&lt;/td&gt;
  &lt;td style="width: 253.567px; height: 21.5px;"&gt;' . $package . '&lt;/td&gt;
  &lt;/tr&gt;';
  
  require "PHPMailer/PHPMailerAutoload.php";
  // require_once "PHPMailer/class.phpmailer.php"; //include phpmailer class
  
  // Instantiate Class  
  $mail = new PHPMailer();
  
  // Set up SMTP  
  $mail-&gt;IsSMTP(); // Sets up a SMTP connection  
  //$mail-&gt;SMTPDebug  = 2;       // enables SMTP debug information (for testing)
  $mail-&gt;SMTPAuth = true; // Connection with the SMTP does require authorization    
  $mail-&gt;SMTPSecure = "ssl"; //"ssl";      // Connect using a TLS connection 
  //$mail-&gt;SMTPSecure = "tls";
  
  //$mail-&gt;Host = "smtp.gmail.com";  //Gmail SMTP server address
  $mail-&gt;Host = "mail.test.com";
  $mail-&gt;Port = '465'; //'465';  //Gmail SMTP port
  $mail-&gt;Encoding = '8bit';
  
  // Authentication  
  
  $mail-&gt;Username = "testuser@test.com";
  $mail-&gt;Password = "password";
  
  
  // Compose
  $mail-&gt;SetFrom( 'testuser@test.com', 'Test' );
  
  $mail-&gt;Subject = "Appointment for $package has been received"; // Subject (which isn't required)  
  $mail-&gt;MsgHTML( $message );
  
  // Send To  
  //$mail-&gt;AddAddress("", "Recipient Name"); // Where to send it - Recipient
  //$mail-&gt;AddAddress("testuser@test.com", "Recipient Name");
  
  
  
  // $result = $mail-&gt;Send();     // Send!  
  //$message = $result ? 'Successfully Sent!' : 'Sending Failed!'; 
  //$message = $result ? header("Location:thank_you.php"); : 'Sending Failed!';      
  //unset($mail);
  
  if ( !$mail-&gt;send() ) {
      echo 'Message could not be sent.';
      echo '&lt;br&gt;Mailer Error: ' . $mail-&gt;ErrorInfo;
  } else {}
  
  
  ?&gt;
  &lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
  
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;!-- Favicon --&gt;
      &lt;link rel="icon" href="favicon.png"&gt;
          &lt;link href="css/main.css" rel="stylesheet" type="text/css"&gt;
      &lt;style&gt;
      .text-xs-center {
      text-align: center !important;
  }
  .jumbotron {
      padding: 4rem 2rem;
  }
  .jumbotron {
      background-color: #eceeef;
      border-radius: 0.3rem;
      margin-bottom: 0rem;
      padding: 5rem 1rem;
  }
          .display-3 {
      font-size: 4.5rem;
      font-family: Poiret One; font-weight: bold;
  }
          .lead {
      font-size: 1.25rem;
      font-weight: 300;
      font-family: Poiret One; font-weight: bold;
  }
  p {
      margin-bottom: 1rem;
      margin-top: 0;
      font-family: Poiret One; font-weight: bold;
  }
      .thankyou-check {
      color: #15639a;
      font-size: 100px;
      text-align: center;
      margin: 6px;    
  }
      &lt;/style&gt;
  
      &lt;script src="js/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="js/bootstrap.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;?php echo  file_get_contents('header.php'); ?&gt;
      &lt;div class="jumbotron text-xs-center"&gt;
      &lt;i class="fa fa-check-circle thankyou-check"&gt;&lt;/i&gt;
    &lt;h1 class="display-3"&gt;Thank You!&lt;/h1&gt;
    &lt;p class="lead"&gt;for your appointment and We will get back to you soon.&lt;/p&gt;
  &lt;/div&gt;  
      &lt;?php echo  file_get_contents('footer.php'); ?&gt;
  &lt;/body&gt;
  
      enter code here
  
  &lt;/html&gt;
  </code></pre>