Some few examples below provides a better insight to how this is done.
Sample: Injecting local variables
<?php
$mailer = new Mailer;
... //other codes here
$mailer->content('mail.template'); // can be defined in $mailer->sendmail()
$mailer->inject(['name' => 'Foo']);
$mailer->sendmail();
Sample: File Template (mail/template.php)
<?php
Hi there {{ $name }} // rendered as Hi there Foo