PHPackages                             eubourne/laravel-mailgun - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. eubourne/laravel-mailgun

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

eubourne/laravel-mailgun
========================

Laravel Mailgun driver.

v1.2.0(8mo ago)08MITPHPPHP ^8.3

Since Nov 25Pushed 8mo ago1 watchersCompare

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

READMEChangelog (3)Dependencies (10)Versions (4)Used By (0)

[![Laravel Mailgun](/assets/laravel-mailgun-card.jpg)](/assets/laravel-mailgun-card.jpg)

Laravel Mailgun
===============

[](#laravel-mailgun)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5c2210c14c4d82d22a5df225e029605f07b70dc3d1833f502e00b62014b88ce9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6575626f75726e652f6c61726176656c2d6d61696c67756e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eubourne/laravel-mailgun)

**Laravel Mailgun** is a custom Laravel Mailgun driver that enables you to configure individual domains for multiple mailers, providing enhanced flexibility and precise control over email delivery.

- [Features](#features)
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Utilities](#utilities)
- [License](#license)
- [Contributing](#contributing)
- [Contact](#contact)

---

Features
--------

[](#features)

- **Per-mailer Domain Configuration:** Assign unique domains to specific mailers, ideal for multi-domain email setups.
- **Powered by the Mailgun API:** Utilizes the official Mailgun API for reliable, secure email delivery.
- **Helper tools:** Includes a user-friendly Artisan command to send test emails, making it easy to verify email configurations and troubleshoot deliverability issues.

---

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

[](#installation)

To install the package, run:

```
composer require eubourne/laravel-mailgun
```

This package supports [Laravel's package auto-discovery](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518) feature, so no manual service provider registration is required.

Basic Usage
-----------

[](#basic-usage)

### 1. Configure Mailgun API Settings

[](#1-configure-mailgun-api-settings)

In your `config/services.php` file, add the Mailgun API credentials:

```
'mailgun-api' => [
    'secret' => env('MAILGUN_SECRET'),
    'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
],
```

### 2. Define a Mailer

[](#2-define-a-mailer)

Update or create a new mailer in your `config/mail.php` file, specifying the `mailgun-api` transport:

```
'mailgun-tx' => [
    'transport' => env('MAIL_TX_TRANSPORT', 'mailgun-api'),
    'from' => [
        'address' => env('MAIL_TX_FROM_ADDRESS', env('MAIL_FROM_ADDRESS')),
        'name' => env('MAIL_FROM_NAME')
    ],
    'domain' => env('MAILGUN_DOMAIN'),
    'logger' => env('MAIL_LOG_CHANNEL'),
],
```

### 3. Set Environment Variables

[](#3-set-environment-variables)

Add the required Mailgun-specific values to your `.env` file.

### 4. Use the Mailer

[](#4-use-the-mailer)

When sending a mailable, specify your custom mailer:

```
Mail::mailer('mailgun-tx')->to($user)->send(new OrderShipped($order));
```

#### Setting a Default Mailer for a Mailable

[](#setting-a-default-mailer-for-a-mailable)

If you want to always send a specific mailable using a particular mailer, you can define it with a public `$mailer` property in your mailable class:

```
class OrderPlaced extends Mailable
{
    public $mailer = 'transactional';
    ...
}
```

Alternatively, you can use the `mailer($mailerName)` method on your mailable instance to set the mailer dynamically at runtime:

```
$mailable = new OrderPlaced();
$mailable->mailer('transactional');
Mail::to($user)->send($mailable);
```

**Important Notes:**

- The mailer specified with the `mailer` property or `mailer()` method will override the mailer used to initiate the send operation.
- For instance, the following code will send the email using the `transactional` mailer, even though the `promotional` mailer is used to send the email:

```
$mailable = new OrderPlaced();
$mailable->mailer('transactional');
Mail::mailer('promotional')->to($user)->send($mailable);
```

This flexibility allows you to set a default mailer for each mailable while retaining the ability to override it dynamically.

---

Utilities
---------

[](#utilities)

The package comes with a helpful Artisan command for testing email configuration and deliverability:

```
php artisan mail:test {email}
```

### Whitelist Addresses

[](#whitelist-addresses)

Before sending test emails, whitelist the recipient addresses by adding a `whitelist` key to your `config/mail.php` file:

```
'whitelist' => ['john.doe@gmail.com']
```

### Example Usage

[](#example-usage)

Send a test email to a whitelisted address:

```
php artisan mail:test john.doe@gmail.com
```

Specify a mailer for the test:

```
php artisan mail:test john.doe@gmail.com --mailer=mailgun-tx
```

Send the email through a specific queue:

```
php artisan mail:test john.doe@gmail.com --queue=mail
```

---

License
-------

[](#license)

This package is open-source and available for free under the [MIT license](http://opensource.org/licenses/MIT).

---

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

[](#contributing)

Feel free to submit issues or pull requests to help improve this package.

---

Contact
-------

[](#contact)

For more information or support, please reach out via GitHub or email.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance59

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~134 days

Total

3

Last Release

265d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1bf96b030aea98256cd79d34205c664a739cf16745fe5da1cc4824267ece26ef?d=identicon)[eubourne](/maintainers/eubourne)

---

Top Contributors

[![cage-a80](https://avatars.githubusercontent.com/u/16155138?v=4)](https://github.com/cage-a80 "cage-a80 (6 commits)")

---

Tags

laravelemailmailermailgun

### Embed Badge

![Health badge](/badges/eubourne-laravel-mailgun/health.svg)

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

###  Alternatives

[propaganistas/laravel-disposable-email

Disposable email validator

5762.6M6](/packages/propaganistas-laravel-disposable-email)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

28160.6k](/packages/boundstate-yii2-mailgun)

PHPackages © 2026

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