即時通訊使用Yii2,我想配置郵件參數geting從數據分貝。從模型配置郵件參數 - Yii2
例子:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'enableSwiftMailerLogging' =>true,
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => $model->getSmtpHost(),
'username' => $model->getSmtpUser(),
'password' => $model->getSmtpPass(),
'port' => $model->getSmtpPort(),
'encryption' => $model->getSmtpEncryption(),
],
]
但web.php不能調用從模型的方法,我試過,但拋出一個錯誤
可能重複的[初始化應用組件與數據庫配置](http://stackoverflow.com/questions/28219440/init-application-component-with-config-from-database) – arogachev