PHPackages                             dansmaculotte/laravel-mail-template - 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. dansmaculotte/laravel-mail-template

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

dansmaculotte/laravel-mail-template
===================================

A mail template driver to send emails with

v4.0.1(3y ago)353.0k3[3 issues](https://github.com/dansmaculotte/laravel-mail-template/issues)MITPHPPHP ^8.1CI failing

Since Jun 16Pushed 3y ago4 watchersCompare

[ Source](https://github.com/dansmaculotte/laravel-mail-template)[ Packagist](https://packagist.org/packages/dansmaculotte/laravel-mail-template)[ Docs](https://github.com/dansmaculotte/laravel-mail-template)[ RSS](/packages/dansmaculotte-laravel-mail-template/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (14)Versions (12)Used By (0)

A laravel mail template driver to send emails with
==================================================

[](#a-laravel-mail-template-driver-to-send-emails-with)

[![Latest Version](https://camo.githubusercontent.com/c373c2c6080ee1470dcbb719d781b2be17f6c6c783ca8b0b6eb17861172ad969/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f44616e734d6143756c6f7474652f6c61726176656c2d6d61696c2d74656d706c6174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dansmaculotte/laravel-mail-template)[![Total Downloads](https://camo.githubusercontent.com/f28ae59684f6624c554e44d4ab99e30fb78480e32c36a57dae817843b74d638b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f44616e734d6143756c6f7474652f6c61726176656c2d6d61696c2d74656d706c6174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dansmaculotte/laravel-mail-template)[![Build Status](https://camo.githubusercontent.com/94066805898f5d33d66239d7155254d2e775c90318c599c9aceb70e4e964be19/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f44616e734d6143756c6f7474652f6c61726176656c2d6d61696c2d74656d706c6174652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/dansmaculotte/laravel-mail-template)[![Quality Score](https://camo.githubusercontent.com/ebe8caaca4b0cd3340f7d34448dc2c61ac30c33f18bb628f0f8417e0a9479468/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f44616e734d6143756c6f7474652f6c61726176656c2d6d61696c2d74656d706c6174652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/dansmaculotte/laravel-mail-template)[![Code Coverage](https://camo.githubusercontent.com/944933b19672faf9f2b9e4d014f5dbe910b9b68c33a8019a4c4b74dccb9b74d0/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f44616e734d6143756c6f7474652f6c61726176656c2d6d61696c2d74656d706c6174652e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/dansmaculotte/laravel-mail-template)

> This package allows you to send emails via mail service providers template's engine.

There are 5 drivers available:

- [Mailchimp](https://mailchimp.com/developer/transactional/api/)
- [Mailjet](https://dev.mailjet.com/guides/#about-the-mailjet-api)
- [Sendgrid](https://sendgrid.com/docs/api-reference/)
- [Mailgun](https://documentation.mailgun.com/en/latest/api_reference.html)
- [SendinBlue](https://developers.sendinblue.com/docs)

There is also and `log` and `null` driver for testing and debug purpose.

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

[](#installation)

### Requirements

[](#requirements)

- PHP 8.1

You can install the package via composer:

```
composer require dansmaculotte/laravel-mail-template
```

The package will automatically register itself.

To publish the config file to config/mail-template.php run:

```
php artisan vendor:publish --provider="DansMaCulotte\MailTemplate\MailTemplateServiceProvider"
```

Finally, install the email service package needed:

- Mailjet

```
composer require mailjet/mailjet-apiv3-php
```

- Mailchimp

```
composer require mailchimp/transactional
```

- SendGrid

```
composer require sendgrid/sendgrid
```

- Mailgun

```
composer require mailgun/mailgun-php
```

- SendinBlue

```
composer require sendinblue/api-v3-sdk
```

Usage
-----

[](#usage)

Configure your mail template driver and credentials in `config/mail-template.php`.

### Basic

[](#basic)

After you've installed the package and filled in the values in the config-file working with this package will be a breeze. All the following examples use the facade. Don't forget to import it at the top of your file.

```
use MailTemplate;
```

```
$mailTemplate = MailTemplate::make()
    ->setSubject('Welcome aboard')
    ->setFrom(config('mail.name'), config('mail.email'))
    ->setRecipient('Recipient Name', 'recipient@email.com')
    ->setLanguage('en')
    ->setTemplate('welcome-aboard')
    ->setVariables([
        'first_name' => 'Recipient',
    ]);

$response = $mailTemplate->send();
```

If an error occurs in the send method it will throw a `SendError::responseError` exception.

### Via Notification

[](#via-notification)

Create a new notification via php artisan:

```
php artisan make:notification WelcomeNotification
```

Set `via` to `MailTemplateChannel`:

```
/**
 * Get the notification's delivery channels.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function via($notifiable)
{
    return [MailTemplateChannel::class];
}
```

Implement `toMailTemplate` method and prepare your template:

```
public function toMailTemplate($notifiable)
{
    return MailTemplate::prepare(
        'Welcome aboard',
        [
            'name' => config('mail.from.name'),
            'email' => config('mail.from.email'),
        ],
        [
            'name' => $notifiable->full_name,
            'email' => $notifiable->email,
        ],
        $notifiable->preferredLocale(),
        'welcome-aboard',
        [
            'first_name' => $notifiable->first_name
        ]
    );
}
```

And that's it. When `MailTemplateChannel` will receive the notification it will automatically call `send` method from `MailTemplate` facade.

### Mailjet Specifics

[](#mailjet-specifics)

Mailjet API allows to set an email to debug templates. When a template error is encountered on email sending, Mailjet sends an error report to this mailbox. To do so, set the email in `config/mail-template.php`, in key `mailjet.debug_email`.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 89.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~138 days

Recently: every ~231 days

Total

10

Last Release

1272d ago

Major Versions

0.1.0 → 1.0.02019-08-19

1.2.1 → 2.0.02020-05-06

2.0.0 → v3.0.02020-11-30

v3.1.0 → v4.0.02022-03-09

PHP version history (3 changes)0.1.0PHP ^7.2

v3.0.0PHP ^7.4

v4.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/498465?v=4)[Gaël Reyrol](/maintainers/GaelReyrol)[@gaelreyrol](https://github.com/gaelreyrol)

![](https://www.gravatar.com/avatar/777575bd441b3393f38a0865d5365a071c18e0989b5a4c9fc90426217876085a?d=identicon)[romain-dmc](/maintainers/romain-dmc)

---

Top Contributors

[![gaelreyrol](https://avatars.githubusercontent.com/u/498465?v=4)](https://github.com/gaelreyrol "gaelreyrol (33 commits)")[![Chroq](https://avatars.githubusercontent.com/u/9250470?v=4)](https://github.com/Chroq "Chroq (2 commits)")[![fstln-joe](https://avatars.githubusercontent.com/u/77104325?v=4)](https://github.com/fstln-joe "fstln-joe (1 commits)")[![rtouze](https://avatars.githubusercontent.com/u/917039?v=4)](https://github.com/rtouze "rtouze (1 commits)")

---

Tags

facadelaravelmailtemplatelaravelmailtemplate

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/dansmaculotte-laravel-mail-template/health.svg)

```
[![Health](https://phpackages.com/badges/dansmaculotte-laravel-mail-template/health.svg)](https://phpackages.com/packages/dansmaculotte-laravel-mail-template)
```

###  Alternatives

[brackets/admin-ui

Administration user interface template

29258.6k3](/packages/brackets-admin-ui)[yansongda/laravel-notification-wechat

Laravel Wechat Notifications Driver

831.4k](/packages/yansongda-laravel-notification-wechat)[sineld/bladeset

A very simple blade extension which allows variables to be set within blade templates.

4423.2k](/packages/sineld-bladeset)[larablocks/pigeon

A more flexible email message builder for Laravel 5 including chained methods, reusable message configurations, and message layout and template view management.

143.7k](/packages/larablocks-pigeon)[muratbsts/mail-template

This package is a easy to use mail template collection for Laravel 5.x.

191.3k](/packages/muratbsts-mail-template)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
