|
1 |
| -# Laravel Mail Log Channel |
2 |
| - |
3 |
| - |
4 |
| -[](https://packagist.org/packages/shaffe/laravel-mail-log-channel) [](https://packagist.org/packages/shaffe/laravel-mail-log-channel) |
5 |
| -[](https://opensource.org/licenses/MIT) |
6 |
| - |
7 |
| -A service provider to add support for logging via email using Laravels built-in mail provider. |
8 |
| - |
9 |
| -This package is a fork of [laravel-log-mailer](https://packagist.org/packages/designmynight/laravel-log-mailer) by Steve Porter. |
10 |
| - |
11 |
| - |
12 |
| - |
13 |
| -## Table of contents |
14 |
| - |
15 |
| -* [Installation](#installation) |
16 |
| -* [Configuration](#configuration) |
17 |
| - |
18 |
| -## Installation |
19 |
| - |
20 |
| -You can install this package via composer using this commande: |
21 |
| - |
22 |
| -```sh |
23 |
| -composer require shaffe/laravel-mail-log-channel |
24 |
| -``` |
25 |
| - |
26 |
| -### Laravel version compatibility |
27 |
| - |
28 |
| - Laravel | Package | |
29 |
| -:------------|:--------| |
30 |
| - 6, 7, 8, 9 | ^2.0 | |
31 |
| - 5.6.x | ^1.0 | |
32 |
| - |
33 |
| -The package will automatically register itself if you use Laravel. |
34 |
| - |
35 |
| -For usage with [Lumen](http://lumen.laravel.com), add the service provider in `bootstrap/app.php`. |
36 |
| - |
37 |
| -```php |
38 |
| -$app->register(Shaffe\MailLogChannel\MailLogChannelServiceProvider::class); |
39 |
| -``` |
40 |
| - |
41 |
| -## Configuration |
42 |
| - |
43 |
| -To ensure all unhandled exceptions are mailed: |
44 |
| - |
45 |
| -1. create a `mail` logging channel in `config/logging.php`, |
46 |
| -2. add this `mail` channel to your current logging stack, |
47 |
| -3. add a `LOG_MAIL_ADDRESS` to your `.env` file to define the recipient. |
48 |
| - |
49 |
| -You can specify multiple channels and individually change the recipients, the subject and the email template. |
50 |
| - |
51 |
| -```php |
52 |
| -'channels' => [ |
53 |
| - 'stack' => [ |
54 |
| - 'driver' => 'stack', |
55 |
| - // 2. Add mail to the stack: |
56 |
| - 'channels' => ['single', 'mail'], |
57 |
| - ], |
58 |
| - |
59 |
| - // ... |
60 |
| - |
61 |
| - // 1. Create a mail logging channel: |
62 |
| - 'mail' => [ |
63 |
| - 'driver' => 'mail', |
64 |
| - 'level' => env('LOG_MAIL_LEVEL', 'notice'), |
65 |
| - |
66 |
| - // Specify mail recipient |
67 |
| - 'to' => [ |
68 |
| - [ |
69 |
| - 'address' => env('LOG_MAIL_ADDRESS'), |
70 |
| - 'name' => 'Error', |
71 |
| - ], |
72 |
| - ], |
73 |
| - |
74 |
| - 'from' => [ |
75 |
| - // Defaults to config('mail.from.address') |
76 |
| - 'address' => env('LOG_MAIL_ADDRESS'), |
77 |
| - // Defaults to config('mail.from.name') |
78 |
| - 'name' => 'Errors' |
79 |
| - ], |
80 |
| - |
81 |
| - // Optionally overwrite the subject format pattern |
82 |
| - // 'subject_format' => env('LOG_MAIL_SUBJECT_FORMAT', '[%datetime%] %level_name%: %message%'), |
83 |
| - |
84 |
| - // Optionally overwrite the mailable template |
85 |
| - // Two variables are sent to the view: `string $content` and `array $records` |
86 |
| - // 'mailable' => NewLogMailable::class |
87 |
| - ], |
88 |
| -], |
89 |
| -``` |
90 |
| - |
91 |
| -### Recipients configuration format |
92 |
| - |
93 |
| -The following `to` config formats are supported: |
94 |
| - |
95 |
| -* single email address: |
96 |
| - |
97 |
| - ```php |
98 |
| - 'to' => env('LOG_MAIL_ADDRESS', ''), |
99 |
| - ``` |
100 |
| - |
101 |
| -* array of email addresses: |
102 |
| - |
103 |
| - ```php |
104 |
| - 'to' => explode(',', env('LOG_MAIL_ADDRESS', '')), |
105 |
| - ``` |
106 |
| - |
107 |
| -* associative array of email => name addresses: |
108 |
| - |
109 |
| - ```php |
110 |
| - 'to' => [env('LOG_MAIL_ADDRESS', '') => 'Error'],` |
111 |
| - ``` |
112 |
| - |
113 |
| -* array of email and name: |
114 |
| - |
115 |
| - ```php |
116 |
| - 'to' => [ |
117 |
| - [ |
118 |
| - 'address' => env('LOG_MAIL_ADDRESS', ''), |
119 |
| - 'name' => 'Error', |
120 |
| - ], |
121 |
| - ], |
122 |
| - ``` |
| 1 | +# Laravel Mail Log Channel |
| 2 | + |
| 3 | + |
| 4 | +[](https://packagist.org/packages/shaffe/laravel-mail-log-channel) [](https://packagist.org/packages/shaffe/laravel-mail-log-channel) |
| 5 | +[](https://opensource.org/licenses/MIT) |
| 6 | + |
| 7 | +A service provider to add support for logging via email using Laravels built-in mail provider. |
| 8 | + |
| 9 | +This package is a fork of [laravel-log-mailer](https://packagist.org/packages/designmynight/laravel-log-mailer) by Steve Porter. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## Table of contents |
| 14 | + |
| 15 | +* [Installation](#installation) |
| 16 | +* [Configuration](#configuration) |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +You can install this package via composer using this commande: |
| 21 | + |
| 22 | +```sh |
| 23 | +composer require shaffe/laravel-mail-log-channel |
| 24 | +``` |
| 25 | + |
| 26 | +### Laravel version compatibility |
| 27 | + |
| 28 | + Laravel | Package | |
| 29 | +:----------------|:--------| |
| 30 | + 6, 7, 8, 9, 10 | ^2.0 | |
| 31 | + 5.6.x | ^1.0 | |
| 32 | + |
| 33 | +The package will automatically register itself if you use Laravel. |
| 34 | + |
| 35 | +For usage with [Lumen](http://lumen.laravel.com), add the service provider in `bootstrap/app.php`. |
| 36 | + |
| 37 | +```php |
| 38 | +$app->register(Shaffe\MailLogChannel\MailLogChannelServiceProvider::class); |
| 39 | +``` |
| 40 | + |
| 41 | +## Configuration |
| 42 | + |
| 43 | +To ensure all unhandled exceptions are mailed: |
| 44 | + |
| 45 | +1. create a `mail` logging channel in `config/logging.php`, |
| 46 | +2. add this `mail` channel to your current logging stack, |
| 47 | +3. add a `LOG_MAIL_ADDRESS` to your `.env` file to define the recipient. |
| 48 | + |
| 49 | +You can specify multiple channels and individually change the recipients, the subject and the email template. |
| 50 | + |
| 51 | +```php |
| 52 | +'channels' => [ |
| 53 | + 'stack' => [ |
| 54 | + 'driver' => 'stack', |
| 55 | + // 2. Add mail to the stack: |
| 56 | + 'channels' => ['single', 'mail'], |
| 57 | + ], |
| 58 | + |
| 59 | + // ... |
| 60 | + |
| 61 | + // 1. Create a mail logging channel: |
| 62 | + 'mail' => [ |
| 63 | + 'driver' => 'mail', |
| 64 | + 'level' => env('LOG_MAIL_LEVEL', 'notice'), |
| 65 | + |
| 66 | + // Specify mail recipient |
| 67 | + 'to' => [ |
| 68 | + [ |
| 69 | + 'address' => env('LOG_MAIL_ADDRESS'), |
| 70 | + 'name' => 'Error', |
| 71 | + ], |
| 72 | + ], |
| 73 | + |
| 74 | + 'from' => [ |
| 75 | + // Defaults to config('mail.from.address') |
| 76 | + 'address' => env('LOG_MAIL_ADDRESS'), |
| 77 | + // Defaults to config('mail.from.name') |
| 78 | + 'name' => 'Errors' |
| 79 | + ], |
| 80 | + |
| 81 | + // Optionally overwrite the subject format pattern |
| 82 | + // 'subject_format' => env('LOG_MAIL_SUBJECT_FORMAT', '[%datetime%] %level_name%: %message%'), |
| 83 | + |
| 84 | + // Optionally overwrite the mailable template |
| 85 | + // Two variables are sent to the view: `string $content` and `array $records` |
| 86 | + // 'mailable' => NewLogMailable::class |
| 87 | + ], |
| 88 | +], |
| 89 | +``` |
| 90 | + |
| 91 | +### Recipients configuration format |
| 92 | + |
| 93 | +The following `to` config formats are supported: |
| 94 | + |
| 95 | +* single email address: |
| 96 | + |
| 97 | + ```php |
| 98 | + 'to' => env('LOG_MAIL_ADDRESS', ''), |
| 99 | + ``` |
| 100 | + |
| 101 | +* array of email addresses: |
| 102 | + |
| 103 | + ```php |
| 104 | + 'to' => explode(',', env('LOG_MAIL_ADDRESS', '')), |
| 105 | + ``` |
| 106 | + |
| 107 | +* associative array of email => name addresses: |
| 108 | + |
| 109 | + ```php |
| 110 | + 'to' => [env('LOG_MAIL_ADDRESS', '') => 'Error'],` |
| 111 | + ``` |
| 112 | + |
| 113 | +* array of email and name: |
| 114 | + |
| 115 | + ```php |
| 116 | + 'to' => [ |
| 117 | + [ |
| 118 | + 'address' => env('LOG_MAIL_ADDRESS', ''), |
| 119 | + 'name' => 'Error', |
| 120 | + ], |
| 121 | + ], |
| 122 | + ``` |
0 commit comments