PHPackages                             matchory/laravel-mailgun-templated-messages - 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. matchory/laravel-mailgun-templated-messages

Abandoned → [matchory/laravel-mailgun-templates-channel](/?search=matchory%2Flaravel-mailgun-templates-channel)Library

matchory/laravel-mailgun-templated-messages
===========================================

A Laravel notification channel for Mailgun's templated messages.

1.1.0(2y ago)237[1 PRs](https://github.com/matchory/laravel-mailgun-templates-channel/pulls)MITPHPPHP &gt;=8.1CI passing

Since Jul 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/matchory/laravel-mailgun-templates-channel)[ Packagist](https://packagist.org/packages/matchory/laravel-mailgun-templated-messages)[ RSS](/packages/matchory-laravel-mailgun-templated-messages/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (7)Versions (8)Used By (0)

Mailgun Templates Messages Notification Channel [![Latest Stable Version](https://camo.githubusercontent.com/8dd31b3c932fc58f4e4aa5e7e0cba8b19a39bcc63ee0be4709abcf6c313597f3/68747470733a2f2f706f7365722e707567782e6f72672f6d617463686f72792f6c61726176656c2d6d61696c67756e2d74656d706c617465732d6368616e6e656c2f76)](https://packagist.org/packages/matchory/laravel-mailgun-templates-channel) [![Total Downloads](https://camo.githubusercontent.com/fb625f001237bbba6e7264b9857505416c42b29d434055a8f1159fbe1363c421/68747470733a2f2f706f7365722e707567782e6f72672f6d617463686f72792f6c61726176656c2d6d61696c67756e2d74656d706c617465732d6368616e6e656c2f646f776e6c6f616473)](https://packagist.org/packages/matchory/laravel-mailgun-templates-channel) [![Latest Unstable Version](https://camo.githubusercontent.com/d0b1bcd781963c7d0a795677c7abf2acf34132e91dea4eb0a30f32730ac80927/68747470733a2f2f706f7365722e707567782e6f72672f6d617463686f72792f6c61726176656c2d6d61696c67756e2d74656d706c617465732d6368616e6e656c2f762f756e737461626c65)](https://packagist.org/packages/matchory/laravel-mailgun-templates-channel) [![License](https://camo.githubusercontent.com/a35590692d90589178d57a340bdb76fba2af5a080eb4adad02f08a4a7ae540ce/68747470733a2f2f706f7365722e707567782e6f72672f6d617463686f72792f6c61726176656c2d6d61696c67756e2d74656d706c617465732d6368616e6e656c2f6c6963656e7365)](https://packagist.org/packages/matchory/laravel-mailgun-templates-channel) [![Laravel Octane Compatible](https://camo.githubusercontent.com/70359a356da237cd29561bc5d0bb80baae775b5ff62f288ed324755382858342/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2532304f6374616e652d436f6d70617469626c652d737563636573733f7374796c653d666c6174266c6f676f3d6c61726176656c)](https://github.com/laravel/octane)
===========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#mailgun-templates-messages-notification-channel-----)

> Provides a notification channel for Mailgun's message templates to Laravel applications.

This library adds a new notification channel to your app that moves email templates from Laravel to Mailgun. This is useful if, for example, you need to send emails from multiple applications, or need a simple way for non-developers to manage email templates.

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

[](#installation)

Install the library from composer:

```
composer require matchory/laravel-mailgun-templates-channel
```

Configuration
-------------

[](#configuration)

Configuration follows the instructions outlined in the Laravel documentation: You should put your Mailgun credentials in the `config/services.php` file:

```
    // ...

    'mailgun' => [

        // Add your mailing domain as registered on Mailgun
        'domain' => env('MAILGUN_DOMAIN', 'mailing.example.com'),

        // Add your Mailgun secret
        'secret' => env('MAILGUN_SECRET'),

        // Optional: Specify the endpoint of Mailgun's EU API if you're a EU
        // customer and need to comply to the GDPR
        'endpoint' => env('MAILGUN_ENDPOINT', 'https://api.eu.mailgun.net'),
    ],

    // ...
```

([back to top](#top))

Usage
-----

[](#usage)

To send message templates, you should first create a template on Mailgun (navigate to "Sending" &gt; "Templates" to manage your templates in the Mailgun web app). Then, create a new notification with a `toMailgun` method:

```
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Matchory\MailgunTemplatedMessages\Messages\MailgunTemplatedMessage;

class TestNotification extends Notification
{
    use Queueable;

    public function __construct(private readonly int $randomNumber) {}

    public function toMailgun(mixed $notifiable): MailgunTemplatedMessage
    {
        return (new MailgunTemplatedMessage('your_template_name'))
            ->from('noreply@example.com')
            ->subject('Test Subject')
            ->param('foo', 'bar')
            ->params([
                'some' => 'more data',
                'available' => 'in your template',
                'name' => $notifiable->name,
                'number' => $this->randomNumber
            ]);
    }
}
```

Send that notification, and you'll receive an email with the rendered template:

```
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Notification;

// number chosen by fair dice roll
Notification::sendNow(Auth::user(), new TestNotification(4));
```

That's it - you're able to use message templates now!

([back to top](#top))

Advanced usage
--------------

[](#advanced-usage)

The `MailgunTemplatedMessage` instance exposes several message building methods to add more metadata to your message. This includes the usual stuff like subject, CC, BCC, recipient, and sender, and also *options* and *params*.
By setting additional options, you can control Mailgun features like delayed delivery and tracking; by setting params, you can add template variables to be used while Mailgun renders the template.

Refer to the [Mailgun documentation](https://documentation.mailgun.com/en/latest/user_manual.html#mailing-lists-1) to learn about the specifics.

### Message options

[](#message-options)

The following methods can be leveraged to handle message options:

```
use Matchory\MailgunTemplatedMessages\Messages\MailgunTemplatedMessage;

$message = new MailgunTemplatedMessage();

// Add an option.
// Note that the value can be anything that can be converted to JSON!
$message->addOption(name: 'skip-verification', value: false);

// Use the fluent methods for chaining several operations together. They all
// have an equivalent getter and setter.
$message->option(name: 'skip-verification', value: false)
        ->option('require-tls', true)

// Set multiple options at once
$message->options([
    'skip-verification' => false,
    'require-tls' => true,
]);

// Check whether options are set
$message->hasOption('require-tls'); // true

// Retrieve all options
$options = $message->getOptions();

// Remove a previously set option. If the option isn't set, this does nothing
$message->removeOption('require-tls');

// Equivalent to the above removeOption() call
$message = $message->withoutOption('require-tls');
```

([back to top](#top))

### Template parameters

[](#template-parameters)

The following methods can be leveraged to handle template rendering parameters:

```
use Matchory\MailgunTemplatedMessages\Messages\MailgunTemplatedMessage;

$message = new MailgunTemplatedMessage();

// Add an param.
// Note that the value can be anything that can be converted to JSON!
$message->addParam(name: 'foo', value: 'bar');

// Use the fluent methods for chaining several operations together. They all
// have an equivalent getter and setter.
$message->param(name: 'foo', value: 'bar')
        ->param('baz', true)

// Set multiple params at once
$message->params([
    'foo' => false,
    'bar' => true,
]);

// Check whether params are set
$message->hasParam('foo'); // true

// Retrieve all params
$params = $message->getParams();

// Remove a previously set param. If the param isn't set, this does nothing
$message->removeParam('foo');

// Equivalent to the above removeParam() call
$message = $message->withoutParam('foo');
```

([back to top](#top))

Managing templates
------------------

[](#managing-templates)

Unfortunately, the Mailgun SDK currently has no facilities to manage message templates, although the API endpoints exist on the Mailgun servers (See [this issue](https://github.com/mailgun/mailgun-php/issues/832) for reference).

As soon as the templates API is implemented, we will add managing capabilities to this library - including automatically updating your message templates from local blade files.

([back to top](#top))

Contributions
-------------

[](#contributions)

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue. Don't forget to give the project a star! Thanks again!

([back to top](#top))

License
-------

[](#license)

Distributed under the MIT License. See [LICENSE](./LICENSE) for more information.

([back to top](#top))

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~93 days

Recently: every ~140 days

Total

7

Last Release

840d ago

Major Versions

0.0.3 → 1.0.02022-07-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/aa633f25468b1a85e85646d55aa16c39d04e163e92744d0a7c2a694dbcafc3e1?d=identicon)[Radiergummi](/maintainers/Radiergummi)

---

Top Contributors

[![Radiergummi](https://avatars.githubusercontent.com/u/6115429?v=4)](https://github.com/Radiergummi "Radiergummi (30 commits)")[![Mohammad-Alavi](https://avatars.githubusercontent.com/u/24431504?v=4)](https://github.com/Mohammad-Alavi "Mohammad-Alavi (2 commits)")

---

Tags

laravelnotificationsmailgunchanneltemplated-messages

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/matchory-laravel-mailgun-templated-messages/health.svg)

```
[![Health](https://phpackages.com/badges/matchory-laravel-mailgun-templated-messages/health.svg)](https://phpackages.com/packages/matchory-laravel-mailgun-templated-messages)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[salamwaddah/laravel-mandrill-driver

Mandrill notification channel for Laravel 5, 6, 7, 8, 9, 10, 11, 12

1174.3k](/packages/salamwaddah-laravel-mandrill-driver)[usamamuneerchaudhary/filament-notifier

A powerful notification system for FilamentPHP that handles multi-channel notifications with template management, scheduling, and real-time delivery. Built for developers who need enterprise-grade notifications without the complexity.

321.1k](/packages/usamamuneerchaudhary-filament-notifier)

PHPackages © 2026

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