I'm trying to send an email from my module and am trying to pass some vars into my module template that I can render using twig. Please note that this is a module template not a front end template.
$first = "john";
$last = "doe";
$mailTo = "john@example.co.uk";
$mailer = Craft::$app->getMailer();
$mailer->htmlLayout = false;
$mailer->textLayout = false;
$mailer->setViewPath('@modules/businessmodule/templates/emails');
$mailer->compose('failed_payment.twig', ['first' => $first, 'last' => $last])
->setTo($mailTo)
->setSubject('Failed Payment')
->setTextBody('Text fallback')
->send();
But I cannot access the vars in my twig template like {{ first }}.
i.e
<p>
Hi, sorry it didn't work out {{ first }} {{ last }}
</p>
Am i missing some parse method somewhere?