PHPackages                             biegalski-llc/laravel-mailgun-webhooks - 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. biegalski-llc/laravel-mailgun-webhooks

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

biegalski-llc/laravel-mailgun-webhooks
======================================

This package allows you to quick and easily integrate your Laravel application with Mailgun Webhooks thus allowing you to track the outgoing email status for each individual user. There is also an optional feature to receive alerts for specific mailgun events such as spam complaints and sending failuresgit .

v1.0.1(5y ago)2398.4k↓27.7%12[4 issues](https://github.com/Biegalski-LLC/Laravel-Mailgun-Webhooks/issues)MITPHPPHP ^7.1|^8.0CI failing

Since Sep 9Pushed 1y ago3 watchersCompare

[ Source](https://github.com/Biegalski-LLC/Laravel-Mailgun-Webhooks)[ Packagist](https://packagist.org/packages/biegalski-llc/laravel-mailgun-webhooks)[ RSS](/packages/biegalski-llc-laravel-mailgun-webhooks/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (25)Used By (0)

New Package
===========

[](#new-package)

This package, `Laravel-Mailgun-Webhooks`, has been superseded by a new and improved solution: [`Notification-Tracker`](https://github.com/Biegalski-LLC/Notification-Tracker).

`Notification-Tracker` offers a more robust, flexible, and maintainable way to handle webhook notifications. We strongly encourage all users to migrate to the new package.

This repository will remain available for reference, but it will no longer be actively maintained.

Thank you for your understanding.

Mailgun Webhooks for Laravel
----------------------------

[](#mailgun-webhooks-for-laravel)

#### Tracking

[](#tracking)

This package allows you to quick and easily integrate your Laravel application with Mailgun Webhooks thus allowing you to track the outgoing email status for each individual user.

- Log when an email was delivered to a specific user
- Log when an email failed to send to a specific user
- etc...

This may be useful information you want to display to your end users or to a certain subset of users (Managers, Moderators, Admins, etc...).

### Email Content Storage

[](#email-content-storage)

This package will also store the content of the emails sent if you need to reference them at any point in the future. There are many use-cases for why this information is valuable.

- Verify a customers complaint with information in the email they received a few weeks ago
- Validate that a customer isn't altering / falsifying an email to benefit their case
- etc...

#### Alerts

[](#alerts)

This package allows gives you the ability to set it up so that you receive alerts for specific things. You have the ability to turn on and off the type of notifications you want to receive.

- Get notified when an email fails to deliver to a user
- Get notified when a user files a spam complaint
- etc...

Installation Instructions
-------------------------

[](#installation-instructions)

Lets begin the installation. First you'll need to install the package with composer.

`composer require biegalski-llc/laravel-mailgun-webhooks`

Next, you will want to publish the configuration and view files.

`php artisan vendor:publish --tag=mailgun_webhook_config`

`php artisan vendor:publish --tag=mailgun_webhook_view`

### Migrations

[](#migrations)

Since the migrations for this package was made in 2019. They can cause problems with newer projects.
Using a user model for instance "App\\Models\\Customer" that was created after 2019. When running tests the migrations will be run on a mock database, which will cause the package migrations to be run before the customers table exist. The package migrations will try to create a relation to your user model. \\

To circumvent this, you can publish the migrations and manually change the timestamps in the file names.

`php artisan vendor:publish --tag=mailgun_webhook_migrations`

DotEnv Configuration Options
----------------------------

[](#dotenv-configuration-options)

Below you will find various options to configure this plugin to your needs.

### Options

[](#options)

Turn on and off certain features of this package

```
MAILGUN_WEBHOOKS_OPTIONS_DISABLE_CONTENT=false
MAILGUN_WEBHOOKS_OPTIONS_DISABLE_FLAG=false
MAILGUN_WEBHOOKS_OPTIONS_DISABLE_TAG=false
MAILGUN_WEBHOOKS_OPTIONS_DISABLE_VARIABLE=false

```

### Notifications

[](#notifications)

Turn on and off various notifications and set who these notifications send to.

```
MAILGUN_WEBHOOKS_ALERTS_TO=
MAILGUN_WEBHOOKS_ALERTS_FROM_EMAIL=
MAILGUN_WEBHOOKS_ALERTS_FROM_NAME=

MAILGUN_WEBHOOKS_TRIGGER_DELIVERED=false
MAILGUN_WEBHOOKS_TRIGGER_OPENED=false
MAILGUN_WEBHOOKS_TRIGGER_PERM_FAILURE=true
MAILGUN_WEBHOOKS_TRIGGER_SPAM=true
MAILGUN_WEBHOOKS_TRIGGER_TEMP_FAILURE=true
MAILGUN_WEBHOOKS_TRIGGER_UNSUBSCRIBE=true

```

### Content Logging

[](#content-logging)

Storing all content can quickly build up disk space used. Turn on and off various pieces of content to store. Only store what you need! `body_html` by default is true, the rest by default are false.

```
MAILGUN_WEBHOOKS_CONTENT_LOG_STRIP_HTML=false
MAILGUN_WEBHOOKS_CONTENT_LOG_STRIP_TEXT=false
MAILGUN_WEBHOOKS_CONTENT_LOG_BODY_HTML=true
MAILGUN_WEBHOOKS_CONTENT_LOG_BODY_PLAIN=false

```

### Custom Database Connection

[](#custom-database-connection)

Storing all of these mailgun notifications in another database? Specify which database connection to use.

```
MAILGUN_WEBHOOKS_CUSTOM_DATABASE=null

```

### User Model

[](#user-model)

By default - we reference the App\\Users model to form the relationship. If you use a custom model or have made changes to the User model - you may need to add and edit these variables to your dotenv as well:

```
MAILGUN_WEBHOOKS_USER_TABLE_NAME=users
MAILGUN_WEBHOOKS_USER_TABLE_EMAIL=email
MAILGUN_WEBHOOKS_USER_TABLE_KEY=id
MAILGUN_WEBHOOKS_USER_TABLE_FPQN=App\Users

```

### Signing Key

[](#signing-key)

Mailgun allows you to set an HTTP webhook signing key, which can be different from the API key value set in the MAILGUN\_SECRET environment variable used to connect to the Mailgun API for sending. This is especailly useful if you use Domain level sending API keys or have rotated the HTTP Webhook signing key. Defaults to the MAILGUN\_SECRET value.

```
MAILGUN_WEBHOOKS_SIGNING_KEY=

```

After you've completed the configuration - lets re-cache it:

`php artisan config:cache`

Now, you'll need to run the database migrations:

`php artisan migrate`

And, finally, you'll need to add a middleware to the route middleware group. In `app\Http\Kernel.php` add the following line to the `routeMiddleware` group:

`'mailgun_webhooks' => \Biegalski\LaravelMailgunWebhooks\Middleware\ValidateMailgunWebhook::class,`

You're all set! Now you just need to add the API endpoints to the webhooks in your Mailgun account.

Add Webhooks In Mailgun
-----------------------

[](#add-webhooks-in-mailgun)

1. Login
2. Navigate to `Sending` -&gt; `Webhooks`
3. Click `Add Webhook` button
4. Select the appropriate `Event Type` and input its corresponding API endpoint. Endpoints listed below:

Event TypeEndpoint URLClicksDelivered MessagesOpened MessagesPermanent FailureSpam ComplaintsTemporary FailureUnsubscribes\*Replace "" with your applications URL.

Usage
-----

[](#usage)

It starts collecting data and sending notifications after configuration is setup. You can dive deeper and extract or display this data. Usage steps for that coming soon!

Affiliations
------------

[](#affiliations)

I have no affiliation with Laravel or Mailgun. Both are just frequently used in projects I am involved in and this package fills a need across various projects.

Translations
------------

[](#translations)

There is currently 9 translations:

- German
- English
- Spanish
- French
- Italian
- Dutch
- Portuguese
- Russian
- Polish

More languages coming soon!

If you're unsure how localization works in Laravel, please reference the documentation at

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Biegalski LLC](https://biegal.ski/)
- [paulredmond](https://gist.github.com/paulredmond/14523d3bd8062f9ce48cdd1340b3f171) - Laravel Middleware to Validate a signed Mailgun Webhook.
- [naszybko](https://github.com/naszybko) - Introducing events pull request and added Laravel 8 support
- [mafftor](https://github.com/mafftor) - Ukrainian translation
- [abordage](https://github.com/abordage) - Case-sensitivity fix
- [alistairreynolds](https://github.com/alistairreynolds) - Foreign key constraint fix
- [PunchRockgroin](https://github.com/PunchRockgroin) - Add Mailgun HTTP webhook signing key configuration
- [affektde](https://github.com/affektde) - Added PHP8 support
- [mharkrollen2](https://github.com/mharkrollen2) - fix table name for custom table

License
-------

[](#license)

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

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 72.7% 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 ~24 days

Recently: every ~47 days

Total

24

Last Release

1930d ago

Major Versions

v0.1.21 → v1.02021-02-04

PHP version history (2 changes)v0.0.1PHP ^7.1

v1.0PHP ^7.1|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/70faf37cc3ff7910e0d0cf44f135832da9cda59ee2f34904abdd83cbb97d0bf3?d=identicon)[Biegalski-LLC](/maintainers/Biegalski-LLC)

---

Top Contributors

[![Biegalski-LLC](https://avatars.githubusercontent.com/u/20915124?v=4)](https://github.com/Biegalski-LLC "Biegalski-LLC (72 commits)")[![da-sie](https://avatars.githubusercontent.com/u/459266?v=4)](https://github.com/da-sie "da-sie (10 commits)")[![abordage](https://avatars.githubusercontent.com/u/28537731?v=4)](https://github.com/abordage "abordage (4 commits)")[![boonstoppel](https://avatars.githubusercontent.com/u/5550179?v=4)](https://github.com/boonstoppel "boonstoppel (2 commits)")[![PunchRockgroin](https://avatars.githubusercontent.com/u/1855836?v=4)](https://github.com/PunchRockgroin "PunchRockgroin (2 commits)")[![alistairreynolds](https://avatars.githubusercontent.com/u/12294764?v=4)](https://github.com/alistairreynolds "alistairreynolds (2 commits)")[![BlueBazze](https://avatars.githubusercontent.com/u/11636062?v=4)](https://github.com/BlueBazze "BlueBazze (2 commits)")[![archilex](https://avatars.githubusercontent.com/u/6097099?v=4)](https://github.com/archilex "archilex (1 commits)")[![jeremykenedy](https://avatars.githubusercontent.com/u/6244570?v=4)](https://github.com/jeremykenedy "jeremykenedy (1 commits)")[![mafftor](https://avatars.githubusercontent.com/u/7810087?v=4)](https://github.com/mafftor "mafftor (1 commits)")[![marklawntalk](https://avatars.githubusercontent.com/u/21285383?v=4)](https://github.com/marklawntalk "marklawntalk (1 commits)")[![affektde](https://avatars.githubusercontent.com/u/5022192?v=4)](https://github.com/affektde "affektde (1 commits)")

---

Tags

phplaravelwebhooksmailgunemail delivery status

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/biegalski-llc-laravel-mailgun-webhooks/health.svg)

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

###  Alternatives

[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

254168.5k](/packages/erag-laravel-disposable-email)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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