title: Yii2 Swift_SmtpTransport gmail not working
body: <p>I'm trying to send an email using yii2 mailer component.</p>
  
  <p>config web.php</p>
  
  <pre><code>'mailer' =&gt; [
      'class' =&gt; 'yii\swiftmailer\Mailer',
      // send all mails to a file by default. You have to set
      // 'useFileTransport' to false and configure a transport
      // for the mailer to send real emails.
      // 'useFileTransport' =&gt; true,
      'transport' =&gt; [
          'class' =&gt; 'Swift_SmtpTransport',
          'host' =&gt; 'smtp.gmail.com',
          'username' =&gt; 'myEmail2131@gmail.com',
          'password' =&gt; 'password1234',
          'port' =&gt; '587',
          'encryption' =&gt; 'tls',
      ]
  ],
  </code></pre>
  
  <p>And my code.</p>
  
  <pre><code>Yii::$app-&gt;mailer-&gt;compose()
          -&gt;setFrom('myEmail07@gmail.com')
          -&gt;setTo('toSomeone@gmail.com')
          -&gt;setSubject('Some Subject here')
          -&gt;setTextBody('Plain text content')
          -&gt;setHtmlBody("&lt;p&gt; This is the body of email&lt;/p&gt;")
          -&gt;send()
  </code></pre>
  
  <p>I'm getting this error.</p>
  
  <blockquote>
    <p>Swift_TransportException Expected response code 250 but got code
    "535", with message "535-5.7.8 Username and Password not accepted.
    Learn more at 535 5.7.8
    <a href="https://support.google.com/mail/?p=BadCredentials" rel="nofollow noreferrer">https://support.google.com/mail/?p=BadCredentials</a>
    a13-v6sm4133042wrc.19 - gsmtp "</p>
  </blockquote>
  
  <p>I already configure my Gmail account as said here <a href="https://stackoverflow.com/questions/42558903/expected-response-code-250-but-got-code-535-with-message-535-5-7-8-username">enter link description here</a></p>
  
  <p><a href="https://myaccount.google.com/lesssecureapps?pli=1" rel="nofollow noreferrer">less secure app on on your gmail account</a></p>
  
  <p>And I also try to use ssl instead tls.</p>
  
  <pre><code>'mailer' =&gt; [
      'class' =&gt; 'yii\swiftmailer\Mailer',
      // send all mails to a file by default. You have to set
      // 'useFileTransport' to false and configure a transport
      // for the mailer to send real emails.
      // 'useFileTransport' =&gt; true,
      'transport' =&gt; [
          'class' =&gt; 'Swift_SmtpTransport',
          'host' =&gt; 'smtp.gmail.com',
          'username' =&gt; 'myEmail2131@gmail.com',
          'password' =&gt; 'password1234',
          'port' =&gt; '465',
          'encryption' =&gt; 'ssl',
      ]
  ],
  </code></pre>
  
  <p>Any idea? Thanks!</p>