PHPackages                             statikbe/laravel-mail-template-engine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. statikbe/laravel-mail-template-engine

ActiveLibrary[Templating &amp; Views](/categories/templating)

statikbe/laravel-mail-template-engine
=====================================

Customizable mail templates for Laravel

1.2.0(2y ago)51.1k11MITPHPPHP ^8.0|^8.1

Since Nov 16Pushed 2y ago3 watchersCompare

[ Source](https://github.com/statikbe/laravel-mail-template-engine)[ Packagist](https://packagist.org/packages/statikbe/laravel-mail-template-engine)[ RSS](/packages/statikbe-laravel-mail-template-engine/feed)WikiDiscussions develop Synced today

READMEChangelog (1)Dependencies (4)Versions (6)Used By (1)

Laravel Mail Template Engine
============================

[](#laravel-mail-template-engine)

The Laravel Mail Template Engine makes it possible to create mail templates for your transactional mails. These mail templates can hold content and recipient variables which can be filled when triggering the mail.

This package works together with our [Laravel Nova Mail Editor](https://github.com/statikbe/laravel-nova-mail-editor) that provides a UI to let content managers edit translations.

How it works
------------

[](#how-it-works)

The packages combines 3 different sets of data to send a transactional mail.

1. Firstly there is the Mail class: here you define a name, content variables and recipient variables.
2. Next up you store your mail templates in your database, you can do this in Nova using [Laravel Nova Mail Editor](https://github.com/statikbe/laravel-nova-mail-editor). Or you write your own interface to save the templates.
3. Finally, you call the mail class and fill in its variables (content and recipient). At this moment the engine will look for all templates using this class, starts filling them with the provided variables and send them to the selected recipients.

Installation
------------

[](#installation)

1. Install using composer:

```
composer require statikbe/laravel-mail-template-engine

```

2. Publish the mail template migration and config

```
php artisan vendor:publish --tag=mail-template-engine

```

3. Run the mail template migration

```
php artisan migrate

```

How to use
----------

[](#how-to-use)

### The mail class

[](#the-mail-class)

This class will decide what content variables are available in your mail template and will be used to decide when a mail is send.

You can generate a mail with the following command

```
php artisan make:mail-class SomeEventMail
```

After creating a Mail class, add them to the config `mail-template-engine.php` mails.

An example of a Mail class can be found at `src/Mails/ResetPassword.php`.

```
