How to send mail using gmail?

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 https://support.google.com/mail/?p=BadCredentials e88sm1040527lji.26 - gsmtp
"

I go out here this error, it turns out it's gmail or not?
in the file common/config/main-local.php
'mailer' => [
 'class' => 'yii\swiftmailer\Mailer',
 'viewPath' => '@common/mail',
 'transport' => [
 'class' => 'Swift_SmtpTransport',
 'host' => 'smtp.gmail.com',
 'username' => 'username@gmail.com',
 'password' => '123456',
 'port' => 465,
 'encryption' => 'ssl',
],

 'useFileTransport' => false,
 ],

Or something I'm doing wrong?
Untrusted applications are allowed allowed and still the same problem
June 27th 19 at 15:25

Find more questions by tags Yii