简体   繁体   中英

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."

//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',
    ],
],
 'default' => [
    'className' => 'Smtp',
    'host' => 'smtp.gmail.com',
    'port' => 587 //or 465,
    'timeout' => 30,
    'username' => 'email',
    'password' => 'pass',
    'client' => null,
    'tls' => true,
],

This config works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM