SMTP server did not accept the password. on upgrade to cakephp3.6

I upgraded my cakephp3.2 to cakephp3.6 . The emailing function doesnt work and i copied the same code in app file from the working emails in cakephp3.2 to the app file in cakephp3.6. The passwords exist and work fine. I edited them here for security. What has changed in 3.6?

It says the “SMTP server did not accept the password.”

i also have the allow less secure apps turned on. I cant email with this setup?

       //in model 
        public function sendemail($to,$from,$subject,$message) {
                     $to='xxxx@gmail.com';
                     $Email = new Email('default');
                 //  $Email->config('gmail3'); 
                    $Email->from(['xxx@gmail.com' => 'My Email'])
                      ->to($to)
                      ->subject($subject)
                      ->send($message);
       
  }//public


//in app file


'EmailTransport' => [
    'default' => [
          'className' => 'Smtp',
        'host' => 'ssl://smtp.gmail.com',
        'port' => 465,
        'username'=>'xx@gmail.com',
        'password'=>'xx',
         'log' => true,
     'context' => [
         'ssl' => [
             'verify_peer' => false,
             'verify_peer_name' => false,
             'allow_self_signed' => true
          ]
         ]
    ],
  ],

  
'Email' => [
    'default' => [
        'transport' => 'default',
        'from' => 'xx@gmail.com',
        //'charset' => 'utf-8',
        //'headerCharset' => 'utf-8',
    ],
],