October CMS Custom Mail Layout

- 1 answer

Ad

I'm struggling to get October CMS to work with custom mail layouts via code. Under Configuration section it states we can use subject and layout.

https://octobercms.com/docs/services/mail#mail-views

I can see the subject is working as expected, however I'm struggling to get any form of layout coming out - its simply chucking out the HTML within the template.

Here is the register.htm template file which is located within my plugins views/mail directory:

subject = "Registration"
layout = "default"

==

Dear {{name}},

Thank you for registering you interest...

Yours sincerely,

Support

==

<p>Dear {{name}},</p>
<br>
<p>Thank you for registering you interest...</p>
<br>
<p>Yours sincerely,</p>
<br>
<p>Support</p>

And I'm calling it like so:

Mail::send('pluginname::mail.register', $data, function($message) use ($data) {
    $message->to($data['email'], $data['name']);
});
Ad

Answer

Ad

Make sure you have registered the mail template in the Plugin.php file so it can be bound to the layout.

public function registerMailTemplates()
{
    return [
        'pluginname::mail.register'  => 'Register template.'
    ];
}
Ad
source: stackoverflow.com
Ad