Back

Data not parsing in my email template


richtestani posted 6 months ago

I have a registration email that is sent out with an activation link which is generated at the time of user creation. I am sending an email after the user is created, along with the activation link and a few other placeholder values.

In my RegistrationController is my mail to method:

\Mail::to($data['email'])
          ->send(new Activation($activation->toString(), $data['username']));

The in my Activation Mailer class:

public function __construct($activation, $username)
{
    //
    $this->activation = $activation;
    $this->site = config('app.name');
    $this->username = $username;


}

public function build()
{
    return $this->view('mail.activation')
              ->from('[email protected]')
              ->with([
                'site' => $this->site,
                'activation' => $this->activation,
                'username' => $this->username,
                'test' => 'My Test Val'
              ]);
}

Then finally, the template looks like any normal blade template complete with {{$activation}} style variables. The mail is sent perfectly but it sends the email without being parsed, so the variables are still in the file.


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us