Mails : inject

Injecting template variables

The inject() method is used to inject local variables into the mail template files which can later be accessed by using placeholder with a dollar sign {{$ }}

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

    

The mail template file accepts pushing forward requests as either get or post request. However, this must be defined in the placeholder.