Mail twig templates
rauwebieten opened this issue · 2 comments
rauwebieten commented
Can I configure the yii2 mailer component to use twig templates?
rauwebieten commented
made it work for now by using:
$mailer = Yii::$app->mailer;
$view = Yii::$app->view;
$bool = $mailer->compose()
->setHtmlBody($view->render('/_emails/email-verification.html.twig', $viewParams))
->setTextBody($view->render('/_emails/email-verification.txt.twig', $viewParams))
->setFrom([Yii::$app->params['adminEmail'] => Yii::$app->name])
->setTo($user->email)
->setSubject('Account registration at ' . Yii::$app->name)
->send();
yii-bot commented
Thank you for your question.
In order for this issue tracker to be effective, it should only contain bug reports and feature requests.
We advise you to use our community driven resources:
If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.
This is an automated comment, triggered by adding the label question
.