Closed adantart closed 8 years ago
Hi.
Currently \yii\mail\BaseMailer::render()
does not support passing additional params to layout (as far as I remember, there was a discussion on the issue).
You may try a workaround like this - I just tried and it worked for me:
$layoutParams = [
// some data to be rendered in layout
...
];
$viewParams = [
// some data to be rendered in view
...
];
$mailer = Yii::$app->getMailer();
$mailer->getView()->params = $layoutParams;
$mailer->compose('viewName', $viewParams)
->setFrom(['admin@example.com' => 'Admin of Example.com'])
->setTo(['user@example.com' => 'Example user'])
->setSubject('Example email')
->send();
Working ! Thanx a lot !
You're welcome
I tried like this: https://github.com/yiisoft/yii2/issues/3590 but it's not working.
Even I tried to access from the view to $this->context->view->params but it's not working.
How can I pass params to the layout ? Thank you !