asahasrabuddhe / laravel-mjml by asahasrabuddhe

A package that enables using MJML with Laravel Mailables.
162,524
114
3
Package Data
Maintainer Username: asahasrabuddhe
Maintainer Contact: ajitem.s@outlook.com (Ajitem Sahasrabuddhe)
Package Create Date: 2018-05-02
Package Last Update: 2024-02-28
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-04-19 15:17:05
Package Statistics
Total Downloads: 162,524
Monthly Downloads: 10,709
Daily Downloads: 535
Total Stars: 114
Total Watchers: 3
Total Forks: 42
Total Open Issues: 14

Laravel MJML

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

  1. Create a view containing MJML in your resources/views directory.

  2. Create a mailable class using artisan command: php artisan make:mail MJMLEmail

  3. In the mailable class, replace

    use Illuminate\Mail\Mailable;

    with

    use Asahasrabuddhe\LaravelMJML\Mail\Mailable;

  4. In the build method, use: $this->mjml('view.name');

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.