Answer the question
In order to leave comments, you need to log in
Why doesn't Yii::$app->set set parameters?
I work with several e-mail addresses with the yii2-imap
extension. I
create a new config for imap connection in the constructor method:
public function __Construct($username, $password) {
$this->address = $username;
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',
],
]);
Yii::$app->set('imap', [
'class' => 'roopz\imap\Imap',
'connection' => [
'imapPath' => '{imap.gmail.com:993/imap/ssl}INBOX',
'imapLogin' => $username,
'imapPassword' => $password,
'serverEncoding'=>'utf-8',
'attachmentsDir'=>'/'
]
]);
;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question