PHPackages                             henryavila/laravel-nova-email-tracking - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. henryavila/laravel-nova-email-tracking

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

henryavila/laravel-nova-email-tracking
======================================

Track e-mail delivery with Mailgun Hooks and display the report on Laravel Nova Dashboard

v3.2.0(4mo ago)11.5k↓50%[3 PRs](https://github.com/henryavila/laravel-nova-email-tracking/pulls)MITPHPPHP ^8.2.0CI passing

Since May 8Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/henryavila/laravel-nova-email-tracking)[ Packagist](https://packagist.org/packages/henryavila/laravel-nova-email-tracking)[ Docs](https://github.com/henryavila/laravel-nova-email-tracking)[ RSS](/packages/henryavila-laravel-nova-email-tracking/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (15)Versions (20)Used By (0)

Rastreamento de e-mail Integrado ao Laravel Nova
================================================

[](#rastreamento-de-e-mail-integrado-ao-laravel-nova)

This is a fork of `henryavila/email-tracking` package. The original package droped support of Laravel Nova. This package was created to keep support for Laravel Nova. This package will not receite update, since I moved from Laravel Nova to Filament

---

Mailgun configuration
---------------------

[](#mailgun-configuration)

On mailgun interface, add a `webhook` to the url `APP_URL/webhooks/mailgun`

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

[](#installation)

Setup Laravel Mail with mailgun at

Define the environments variable in your `.env` file

```
MAIL_MAILER=mailgun
MAILGUN_DOMAIN=yourdomain.com
MAILGUN_SECRET=key-99999999999999999999999999999999

```

Install the package via composer:

```
composer require henryavila/laravel-nova-email-tracking
```

Publish and run the migrations with:

```
php artisan vendor:publish --tag="email-tracking-migrations"
php artisan migrate
```

Publish the config file with:

```
php artisan vendor:publish --tag="email-tracking-config"
```

This is the contents of the published config file:

```
return [
    /**
     * if defined, the Email model will use this database connection.
     * This connection name must be defined in database.connections config file
     */
    'email-db-connection' => null,

    /**
     * Save the HTML Body of all sent messages
     */
    'log-body-html' => true,

    /**
     * Save the TXT Body of all sent messages
     */
    'log-body-txt' => true,
];
```

Publish the lang files (optional) with:

```
php artisan vendor:publish --tag="email-tracking-translations"
```

---

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

[](#configuration)

On `NovaServiceProvider.php`, add the code:

```
    /**
     * Get the tools that should be listed in the Nova sidebar.
     *
     * @return array
     */
    public function tools()
    {
        \HenryAvila\LaravelNovaEmailTracking\Nova\LaravelNovaEmailTrackingTool::make()
    }
```

This will display the e-mails on Laravel Nova Dashboard.

If you need to customize the Nova Resource, just create a new one extending `HenryAvila\LaravelNovaEmailTracking\Nova\EmailResource` and use this code

```
    /**
     * Get the tools that should be listed in the Nova sidebar.
     *
     * @return array
     */
    public function tools()
    {
        \HenryAvila\LaravelNovaEmailTracking\Nova\LaravelNovaEmailTrackingTool::make()
            ->emailResource(CustomEmailResource::class)
    }
```

---

On all models that can send e-mail, and add the trait `ModelWithEmailsSenderTrait`

On `EventServiceProvider.php`, add the code

```
   /**
     * The event listener mappings for the application.
     *
     * @var array
     */
   protected $listen = [
        \Illuminate\Mail\Events\MessageSent::class => [
            \HenryAvila\LaravelNovaEmailTracking\Listeners\LogEmailSentListener::class,
        ],
   ];
```

At this point, all e-mail sent from app, will be logged on the app, but the sender will not be saved

Save the Email sender
---------------------

[](#save-the-email-sender)

To be able to track the e-mail sender, you must create a custom `Mailable` or `Notification`. the default mail can't define the sender (like Nova Reset password e-mail)

### Mailable

[](#mailable)

When creating a new Mailable, overwrite the Base Mailable Class with `HenryAvila\LaravelNovaEmailTracking\Mail\TrackableMail`

Also, You must change the constructor and content function.

This is the default mail class:

```
class SampleMail extends \Illuminate\Mail\Mailable
{
    public function __construct()
    {
        //
    }

    public function content(): Content
    {
        return new Content(
            view: 'view.name',
        );
    }
}
```

It must be overwritten by this one:

```
class SampleMail extends \HenryAvila\LaravelNovaEmailTracking\Mail\TrackableMail
{
    public function __construct($modelSender)
    {
        $viewData = [];
        parent::__construct($modelSender, 'view.name', $viewData]);
    }
}
```

To send the Mailable, just pass the model in the mailable constructor

```
// example: Send the Sample Mail to User with id 1
$user = User::find(1);
Mail::to($user)->send(new App\Mail\SampleMail($user));
```

### Notification

[](#notification)

When creating a notification, all you have to do is to change the `toMail()` method. Replace the default code:

```
public function toMail($notifiable): MailMessage
{
    return (new MailMessage)
        ->line('The introduction to the notification.')
        ->action('Notification Action', url('/'))
        ->line('Thank you for using our application!');
}
```

with this code:

```
public function __construct(public \Illuminate\Database\Eloquent\Model $model)
{
    //
}

public function toMail($notifiable): MailMessage
{
    return (new \HenryAvila\LaravelNovaEmailTracking\Notifications\TrackableNotificationMailMessage($this->model))
        ->line('The introduction to the notification.')
        ->action('Notification Action', url('/'))
        ->line('Thank you for using our application!');
}
```

To send the notification

```
// User with id 1 send the sample notification to multiple $clientes
$user = User::find(1);
Notification::send($clientes, new SampleNotification($user));
```

---

Displaying the e-mails from sender
----------------------------------

[](#displaying-the-e-mails-from-sender)

To be able to display the e-mails sent from a send, add this code in the `fields()` method on nova resource

```
public function fields(Request $request)
{
    return [
        ...
        \HenryAvila\LaravelNovaEmailTracking\LaravelNovaEmailTracking::hasManyEmailsField(),
        ...
    ];
}
```

---

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Henry Ávila](https://github.com/henryavila)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance76

Regular maintenance activity

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 75.3% 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 ~84 days

Recently: every ~123 days

Total

8

Last Release

144d ago

Major Versions

v1.0.0 → v2.0.02024-08-13

v2.0.3 → v3.0.02025-03-31

PHP version history (2 changes)v1.0.0PHP ^8.1.0

v3.0.0PHP ^8.2.0

### Community

Maintainers

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

---

Top Contributors

[![henryavila](https://avatars.githubusercontent.com/u/8429941?v=4)](https://github.com/henryavila "henryavila (61 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (10 commits)")

---

Tags

laravellaravel-novaEmail Trackinghenryavila

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/henryavila-laravel-nova-email-tracking/health.svg)

```
[![Health](https://phpackages.com/badges/henryavila-laravel-nova-email-tracking/health.svg)](https://phpackages.com/packages/henryavila-laravel-nova-email-tracking)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[spatie/laravel-slack-alerts

Send a message to Slack

3212.6M4](/packages/spatie-laravel-slack-alerts)[keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

142347.8k](/packages/keepsuit-laravel-opentelemetry)[spatie/laravel-error-share

Share your Laravel errors to Flare

43965.6k3](/packages/spatie-laravel-error-share)[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)

PHPackages © 2026

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