![](/img/trans.png)
[英]cakephp email error with SMTP server did not accept the password. Less secure apps is enabled
[英]SMTP server did not accept the password. on upgrade to cakephp3.6
我將cakephp3.2升級到cakephp3.6。 電子郵件功能不起作用,我將cakephp3.2中工作電子郵件中的應用程序文件中的相同代碼復制到cakephp3.6中的應用程序文件中。 密碼存在並且可以正常工作。 為了安全起見,我在這里進行了編輯。 3.6中發生了什么變化?
它說“ SMTP服務器不接受密碼”。
//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,
],
這個配置對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.