Skip to main content
Mail Notifications · Revision #1

How do I override the html content of a mailable?

How do I override the html content of a mailable?

You can set the HTML of a Mailable using the html() method.

For example, the email builder uses this to render the HTML of the email from the template, rather than the body:

\Aero\Events\ManagedEvent::whenSendingAsMail(function (\Aero\Events\Actions\Mailable $mailable, \Aero\Events\ManagedEvent $event) {
    $action = $mailable->action();

    if (! empty($action->body)) {
        return;
    }

    $mailable->html(
        \Aero\EmailBuilder\Facades\EmailBuilder::renderTemplate((array) $event, $action->getKey())
    );
});