在app_local中,我如何在cakephp 4中用变量设置用户名和密码?我想从表中获取值。或者如果我不能用变量来设置电子邮件,那么有其他方法吗?
'EmailTransport' => [
'default' => [
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username'=>'xx@gmail.com',
'password'=>'xx',
//how can i do this code below with the variables as i cant get data from a table in this file?
'EmailTransport' => [
'default' => [
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username'=>$username,
'password'=>$password,
1条答案
按热度按时间chhkpiq41#
在配置文件中保留默认电子邮件设置。
在你的控制器动作中做类似这样的事情:
或试试这个:
阅读更多信息https:book.cakephp.org/4/en/core-libraries/email.html#configuring-transports
**注意:**出于安全原因,请确保不要将纯文本密码保存到数据库中