title: Cannot connect to gmail SMTP Server
body: <p>I am using cakephp 3.0. I am trying to send mail using cakephp through gmail SMTP Server. I am trying to do it from my localhost so I don't have ssl. This is the configuration I've done in app.php:</p>
  
  <pre><code>'EmailTransport' =&gt; [
      'gmail'=&gt;[
          'className'=&gt;'Smtp',
          'host'=&gt;'smtp.gmail.com',
          'port'=&gt;587,
          'timeout' =&gt; 60,
          'username'=&gt;'myemail@gmail.com',
          'password'=&gt;'mypassword',
          'tls' =&gt; true,
      ]
  ]
  </code></pre>
  
  <p>This is where I've created my email profile :</p>
  
  <pre><code>'Email' =&gt; [
      'gmail' =&gt; [
          'transport' =&gt; 'gmail',
          'from' =&gt; 'myemail@gmail.com'
      ]
  ],
  </code></pre>
  
  <p>This is the code from my custom mailer class :</p>
  
  <pre><code>    $mail
          -&gt;to($email)
          -&gt;profile('gmail')
          -&gt;subject($this-&gt;subject)
          -&gt;emailFormat('html')
          -&gt;template('welcome')
          -&gt;viewVars([
              $name=&gt;$name,
              $code=&gt;$code
          ]);
  </code></pre>
  
  <p>I've already allowed access to less secure apps in my gmail account. This is the error cakephp is throwing :</p>
  
  <blockquote>
    <p>SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS</p>
  </blockquote>
  
  <p>Attaching a complete snapshot of the error :</p>
  
  <p><a href="https://i.stack.imgur.com/dcoHE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dcoHE.png" alt="enter image description here"></a></p>