Looking to hire Laravel developers? Try LaraJobs

laravel-log-mail maintained by confetticode

Description
Laravel - Sending log records via mail channels
Author
Last update
2025/06/20 05:44 (dev-main)
License
Links
Downloads
5

Comments
comments powered by Disqus

Laravel Log Mail

Packagist Test Downloads

Supported PHP 8.2+ and Laravel 11+

Installation

composer require confetticode/laravel-log-mail

Usage

Configure a mail channel.

<?php

return [
    // ...
    'channels' => [
        'mail' => [
            'driver' => 'mail',
            'mailer' => env('LOG_MAIL_MAILER'),
            'name' => env('LOG_MAIL_NAME'),
            'level' => env('LOG_MAIL_LEVEL'),
            'bubble' => env('LOG_MAIL_BUBBLE'),
            'from' => [
                'address' => env('LOG_MAIL_FROM_ADDRESS'),
                'name' => env('LOG_MAIL_FROM_NAME'),
            ],
            'to' => [
                'address' => env('LOG_MAIL_TO_ADDRESS'),
                'name' => env('LOG_MAIL_TO_NAME'),
            ],
        ],
    ],
    // ...
];

Log an error via the mail channel.

<?php

use Illuminate\Support\Facades\Log;

try {
    new UndefinedClass;
} catch (\Throwable $e) {
    Log::channel('mail')->error($e->getMessage(), ['exception' => $e]);
}

Use the mail channel as a part of the log stack.

LOG_STACK=daily,mail

License (MIT)

The confetticode/laravel-log-mail package is licensed under the MIT license.