asahasrabuddhe / laravel-mjml
A package that enables using MJML with Laravel Mailables.
Installs: 240 142
Dependents: 0
Suggesters: 0
Security: 0
Stars: 123
Watchers: 3
Forks: 51
Open Issues: 10
Requires
- soundasleep/html2text: ~2.1.0
- symfony/process: ^4.0.0|^5.0.0|^6.0.0
Requires (Dev)
- orchestra/testbench: ~6.35.0
- php-coveralls/php-coveralls: ^2.5.2
- dev-master
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.2.2
- 0.1.2.1
- 0.1.2
- 0.1.1
- 0.1.0
- dev-composer-update-conficts
- dev-dependabot/composer/league/flysystem-1.1.4
- dev-dependabot/composer/orchestra/testbench-4.17.0
- dev-dependabot/composer/symfony/process-4.4.27
- dev-dependabot/composer/laravel/framework-6.20.30
- dev-dependabot/add-v2-config-file
- dev-dependabot/composer/php-coveralls/php-coveralls-2.4.3
- dev-dependabot/composer/soundasleep/html2text-1.1.0
- dev-analysis-x0JP6M
- dev-develop
This package is auto-updated.
Last update: 2024-11-14 06:41:14 UTC
README
Build responsive e-mails easily using MJML and Laravel Mailables.
MJML
MJML is an awesome tool from MailJet that allows us to create responsive emails very easily. For more information on how to use it, head to their documentation here
Installation
To install this package, require this package using composer as follows:
composer require asahasrabuddhe/laravel-mjml
After composer installs the packages and all the dependencies, publish the package configuration using artisan command:
php artisan vendor:publish
Select the laravel-mjml in the list. You will also need to install the MJML CLI:
npm install --save mjml
Getting Started
-
Create a view containing MJML in your resources/views directory.
-
Create a mailable class using artisan command:
php artisan make:mail MJMLEmail
-
In the mailable class, replace
use Illuminate\Mail\Mailable;
with
use Asahasrabuddhe\LaravelMJML\Mail\Mailable;
-
For Laravel 8 and below, in the
build
method, use:public function build() { return $this->mjml('view.name') }
For Laravel 9, in the
content
method:, use:public function content() { return new Content( view: $this->mjml('view.name')->buildMjmlView()['html'], ); }
Configuration
By default, the package will automatically detect the path of the MJML CLI installed locally in the project. In case this does not happen or the MJML CLI is installed globally, please update the configuration file likewise.
That's it! You have successfully installed and configured the MJML package for use. Just create new views and use them in the mailables class.