title: use phpmailer to send email from localhost to gmail: SMTP connect() failed
body: <p>i want to send an email from localhost to gmail, but it says "SMTP connect() failed"
  here is my code. I've also tried to change configuration php.ini and sendmail.ini but no luck.
  Thank you.</p>
  
  <pre><code>    $mail = new PHPMailer;
  
      $mail-&gt;isSMTP();       
      $mail-&gt;SMTPSecure = 'ssl'; 
      $mail-&gt;Host = 'smtp.gmail.com'; 
      $mail-&gt;Port = 465;
      $mail-&gt;SMTPAuth = true;                               
      $mail-&gt;Username = 'asd@gmail.com';               
      $mail-&gt;Password = 'password';                   
  
      $mail-&gt;From = 'from@example.com';
      $mail-&gt;FromName = 'Mailer';
      $mail-&gt;addAddress('asd@gmail.com');           
  
      $mail-&gt;WordWrap = 50;                            
      $mail-&gt;isHTML(true);                          
  
      $mail-&gt;Subject = 'Email'
      $mail-&gt;Body    = "This is body";
  
      if(!$mail-&gt;send()) {
          echo 'Message could not be sent.';
          echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
      } else {
          echo 'Message has been sent';
      }
  </code></pre>