shaffe/laravel-mail-log-channel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shaffe/laravel-mail-log-channel

最新稳定版本:v2.5.0

Composer 安装命令:

composer require shaffe/laravel-mail-log-channel

包简介

A package to support logging via email in Laravel

README 文档

README

Latest Stable Version Total Downloads License: MIT

A service provider to add support for logging via email using Laravels built-in mail provider.

This package is a fork of laravel-log-mailer by Steve Porter.

image

Table of contents

Installation

You can install this package via composer using this commande:

composer require shaffe/laravel-mail-log-channel

Laravel version compatibility

Laravel Package
6, 7, 8, 9, 10, 11, 12 ^2.0
5.6.x ^1.0

The package will automatically register itself if you use Laravel.

For usage with Lumen, add the service provider in bootstrap/app.php.

$app->register(Shaffe\MailLogChannel\MailLogChannelServiceProvider::class);

Configuration

To ensure all unhandled exceptions are mailed:

  1. create a mail logging channel in config/logging.php,
  2. add this mail channel to your current logging stack,
  3. add a LOG_MAIL_ADDRESS to your .env file to define the recipient.

You can specify multiple channels and individually change the recipients, the subject and the email template.

'channels' => [
    'stack' => [
        'driver' => 'stack',
        // 2. Add mail to the stack:
        'channels' => ['single', 'mail'],
    ],

    // ...

    // 1. Create a mail logging channel:
    'mail' => [
        'driver' => 'mail',
        'level' => env('LOG_MAIL_LEVEL', 'notice'),

        // Specify mail recipient
        'to' => [
            [
                'address' => env('LOG_MAIL_ADDRESS'),
                'name' => 'Error',
            ],
        ],

        'from' => [
            // Defaults to config('mail.from.address')
            'address' => env('LOG_MAIL_ADDRESS'),
            // Defaults to config('mail.from.name')
            'name' => 'Errors'
        ],

        // Optionally overwrite the subject format pattern
        // 'subject_format' => env('LOG_MAIL_SUBJECT_FORMAT', '[%datetime%] %level_name%: %message%'),

        // Optionally overwrite the mailable template
        // Two variables are sent to the view: `string $content` and `array $records`
        // 'mailable' => NewLogMailable::class
    ],
],

Recipients configuration format

The following to config formats are supported:

  • single email address:

    'to' => env('LOG_MAIL_ADDRESS', ''),
  • array of email addresses:

    'to' => explode(',', env('LOG_MAIL_ADDRESS', '')),
  • associative array of email => name addresses:

    'to' => [env('LOG_MAIL_ADDRESS', '') => 'Error'],`
  • array of email and name:

    'to' => [
         [
             'address' => env('LOG_MAIL_ADDRESS', ''),
             'name' => 'Error',
         ],
     ],

统计信息

  • 总下载量: 78.94k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-29