title: SMTP GMAIL Connection
body: <p>I can't connect to SMTP GMAIL with PHPMailer.</p>
  
  <p>here is error : </p>
  
  <blockquote>
    <p>Error on Jun 25, 2015 22:54PM - stream_socket_client(): unable to
    connect to smtp.gmail.com:587 (Connection timed out) in
    /home/amiroper/public_html/beporsbedoon/app/helpers/phpmailer/smtp.php
    on line 222</p>
  </blockquote>
  
  <p>and this is my code :</p>
  
  <pre><code>$this-&gt;_mail-&gt;isSMTP();
  $this-&gt;_mail-&gt;Host = "smtp.gmail.com";
  $this-&gt;_mail-&gt;SMTPAuth = true;
  $this-&gt;_mail-&gt;Username = "amiroperator@gmail.com";
  $this-&gt;_mail-&gt;Password = "*********";
  $this-&gt;_mail-&gt;SMTPSecure = "tls";
  $this-&gt;_mail-&gt;Port = "587";
  $this-&gt;_mail-&gt;SMTPDebug = 4;
  $this-&gt;_mail-&gt;From = "AmirOperator";
  $this-&gt;_mail-&gt;FromName = 'amiroperator@gmail.com';
  $this-&gt;_mail-&gt;addAddress("amiroperator@outlook.com", "test");
  $this-&gt;_mail-&gt;isHTML(true);
  $this-&gt;_mail-&gt;Subject = 'Registration confirm';
  $this-&gt;_mail-&gt;Body    = 'Thank you for registering to activate your account please click on this link. ".DIR."account/activate/$id/$activasion"';
  $this-&gt;_mail-&gt;AltBody = 'Thank you for registering to activate your account please click on this link. ".DIR."account/activate/$id/$activasion"';
  
  if(!$this-&gt;_mail-&gt;send()) {
      $data['mailsent'] = false;
  } else {
      $data['mailsent'] = true;
  }
  </code></pre>
  
  <p>the php code is wrong or this is connection problem</p>