Effortlessly craft responsive email templates using MJML within Laravel Mailables
webnuvola/laravel-mjml is a Laravel package for effortlessly craft responsive email templates using mjml within laravel mailables.
It currently has 1 GitHub stars and 6.860 downloads on Packagist (latest version v1.0.1).
Install it with composer require webnuvola/laravel-mjml.
Discover more Laravel packages by webnuvola
or browse all Laravel packages to compare alternatives.
Last updated
Effortlessly craft responsive email templates using MJML within Laravel Mailables.
To use this package, follow these steps after generating a new Mailable.
Instead of extending Illuminate\Mail\Mailable, extend Webnuvola\Laravel\Mjml\Mailable.
In the Mailable class, define the build method.
You can now use the mjml method for defining a view or mjmlContent to directly pass the MJML template.
Here's an example:
use Webnuvola\Laravel\Mjml\Mailable;
class TestMail extends Mailable
{
/**
* Build the message.
*/
public function build(): void
{
$this->mjml('emails.orders.shipped', [
'order' => $order,
]);
}
}
You can install the package via composer:
composer require webnuvola/laravel-mjml
In your project, or on your server, you must have the JavaScript package mjml installed.
npm install mjml
Make sure you have installed Node 16 or higher.
This package uses spatie/mjml-php under the hood.
composer test
Please see CHANGELOG for more information on what has changed recently.
Inspired by asahasrabuddhe/laravel-mjml package.
The MIT License (MIT). Please see License File for more information.