PHPackages                             timedoor/mail-logger - 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. timedoor/mail-logger

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

timedoor/mail-logger
====================

Outcoming email logger for Laravel

1.1.3(3y ago)0221MITPHPPHP &gt;=7.1.3

Since Nov 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/backend-timedoor/mail-logger)[ Packagist](https://packagist.org/packages/timedoor/mail-logger)[ RSS](/packages/timedoor-mail-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

Laravel Mail Logger
-------------------

[](#laravel-mail-logger)

---

A laravel package to log outgoing emails and resend. This package will store all outgoing emails inside database and will track their status if they are successfully sent or not.

### Installation

[](#installation)

This package can be installed using composer.

```
composer require timedoor/mail-logger
```

It will automatically detected by Laravel, but you could register the package's service provider manually by adding the below line to `providers` array inside `config/app.php` file.

```
    'providers' => [
        //
        \Timedoor\MailLogger\MailLoggerServiceProvider::class
    ]
```

By default, this package will use `mail_logs` as table name on database migration, but you could change it by editting `config/mail_logger.php`. Before that, you need to publish the configuration by running

```
php artisan vendor:publish --tag=mail-logger
```

Run migrations to create the table required to store the emails.

```
php artisan migrate

```

This will create a table `mail_logs`, or any name you gives on configuration file.

### Usage

[](#usage)

By default this package records all the outgoing mailables and notifications.

### Ignoring Mailables And Notifications From Being Recorded

[](#ignoring-mailables-and-notifications-from-being-recorded)

If you wish to ignore certain mailables or notifications from being recorded, You can add them to `ignore` array in `config/mail_logger.php` file.

#### Resending Mails

[](#resending-mails)

You can resend any mail by using the following command

```
php artisan mail-logger:resend-mail 1
```

Here 1 represents the ID of the mail to resend. The command above will send email as the logged mail sent, for example: if you send using queue, it will resend email using queue, too. In case you want to send the mail immediately, you can add option `--now`.

```
php artisan mail-logger:resend-mail 1 --now
```

#### Resending All Un-Sent Mails

[](#resending-all-un-sent-mails)

If you wish to resend all the mails which are unsent, You can use the following artisan command

```
php artisan mail-logger:resend-unsent-mail
```

or

```
php artisan mail-logger:resend-unsent-mail --now
```

Since this command will only resend the mails which are failed to send, You can safely schedule this command to resend your failed emails.

```
$schedule->command('mail-logger:resend-unsent-mail')->daily();
```

#### Deleting Older Entries

[](#deleting-older-entries)

Since this package records all outgoing emails, Your database table will start growing quickly. To automatically delete older entires, This package provides an artisan command to schedule deletion of older entries.

You can schedule deletion of older entries by adding the following line to your scheduler.

```
$schedule->command('mail-logger:prune --hours=72')->daily();
```

This will delete all entries which are older than 72 hours.

#### Run it via controller

[](#run-it-via-controller)

If you want to resend or prune emails via controller, please look at the example below

```
