M
M
Maxim Lagoysky2017-05-11 11:18:29
Yii
Maxim Lagoysky, 2017-05-11 11:18:29

How to specify your own text in the letter instead of the sender?

Now I'm trying to write like this.

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'messageConfig' => [
                'from' => ['[email protected]' => 'test'],
            ],
        ],

but it still says to me that from '[email protected]', where am I doing something wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2017-05-11
@slo_nik

Good morning.
Try using compose() to do this.
More or less like this:

Yii::$app->mailer->compose('@app/modules/users/mails/passwordReset', ['user' => $user])
                    ->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])
                    ->setTo($this->email)
                    ->setSubject('Password reset for ' . Yii::$app->name)
                    ->send();

M
Maxim Lagoysky, 2017-05-12
@lagoy

As far as I understand it should be written like this?

Yii::$app->mailer->compose('@app/modules/users/mails/passwordReset', ['user' => $user])
                    ->setFrom([Yii::$app->params['supportEmail'] => 'sssssssssssssssssssss'])
                    ->setTo($this->email)
                    ->setSubject('Password reset for ' . Yii::$app->name)
                    ->send();

If so, did something not work, or did I do something wrong?

D
Denis Rybin, 2017-05-12
@RybinDen

Change the value of the supportEmail key to your own text in the configuration file-params.php.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question