S
S
Sergey2017-09-26 22:56:04
Yii
Sergey, 2017-09-26 22:56:04

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'=>'/'
            ]
        ]);


       ;
   }

The code worked, but fell off and it is not clear why.
The new object for the new mail still has the old connection.
Those. or Yii::$app->set doesn't start (for new config parameters), why?
Either you need to restart the yii application (how?)
Or interrupt the previous connection (there is no method in this extension, but I don’t think it will help, because the object is created new, but the problem is in the config).
What will be the advice?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question