Reputation: 3051
Yii::$app->mailer->compose('order-html', ['myVar' => 'HALLO' ])
->setTo(Yii::$app->params['adminEmail'])
->setFrom(Yii::$app->params['adminEmail'])
->setSubject('Ihre Trauring-Bestellung ist eingegangen')
->send();
How can I access the myVar-var in my mail-view order-html.php?
Upvotes: 2
Views: 1726
Reputation: 344
swiftmailer:
Yii::$app->mailer->compose('other', ['myVar' => 'HALLO'])
->setFrom('[email protected]')
->setTo('[email protected]')
->setSubject('Message subject')
->send();
in other.php:
<?=$myVar; ?>
Upvotes: 3
Reputation: 9367
When you call Yii::$app->mailer->compose('order-html'
you are actually calling a view and assigning the result of the view to the body of the email, so you would access the variables exactly how you would do in a view (because it is a view).
Upvotes: 2