Yii::$app->set('mailer', [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
// Values from db
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => $username,
'password' => $password,
'port' => '587',
'encryption' => 'tls',
],
]);