Skip to content

Commit bd0fb06

Browse files
committed
doc: Update readme
1 parent 13d8622 commit bd0fb06

File tree

1 file changed

+59
-6
lines changed

1 file changed

+59
-6
lines changed

README.md

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,44 @@
2020
</a>
2121
</p>
2222

23-
# Laravel Mail Logger & Viewer
23+
# Laravel Mail Viewer
2424

2525
Easily log, view, and search outgoing emails directly in your browser.
2626

27-
![Preview Light](./art/v3-light.png "Preview Light")
28-
![Preview Dark](./art/v3-dark.png "Preview Dark")
27+
![Screenshot of Laravel Mail Viewer - Light Mode](./art/v3-light.png "Preview Light")
28+
![Screenshot of Laravel Mail Viewer - Dark Mode](./art/v3-dark.png "Preview Dark")
2929

3030
This package logs all outgoing emails to a database and provides a web interface to view them, formatted as they appear in modern email clients like Gmail.
3131

3232
---
3333

34-
## Installation
34+
<!-- TOC -->
35+
* [Laravel Mail Viewer](#laravel-mail-viewer)
36+
* [Features](#features)
37+
* [Installation](#installation)
38+
* [Step 1: Install via Composer](#step-1-install-via-composer)
39+
* [Step 2: Publish Assets & Configurations](#step-2-publish-assets--configurations)
40+
* [Step 3: Run Migrations](#step-3-run-migrations)
41+
* [Step 4: View Emails](#step-4-view-emails)
42+
* [Configuration](#configuration)
43+
* [Data Pruning](#data-pruning)
44+
* [Production Usage](#production-usage)
45+
* [Restrict Access with Middleware](#restrict-access-with-middleware)
46+
* [Disable package in production mode](#disable-package-in-production-mode)
47+
* [Disable auto-discovery:](#disable-auto-discovery)
48+
* [Register package for non-production environments](#register-package-for-non-production-environments)
49+
* [License](#license)
50+
* [Credits](#credits)
51+
<!-- TOC -->
52+
53+
## Features
54+
- Logs all outgoing emails to the database
55+
- Modern in-browser email viewer
56+
- Searchable UI with auto-refreshing entries
57+
- Configurable route and access protection
58+
- Optional email pruning
3559

60+
## Installation
3661
### Step 1: Install via Composer
3762

3863
Run the following command in your terminal:
@@ -80,15 +105,19 @@ The package supports Laravel's [Model Pruning](https://laravel.com/docs/eloquent
80105
By default, the email viewer is publicly accessible.
81106
In a production environment, it's highly recommended to restrict access
82107
using middleware or something like [Access Screen](https://github.com/MasterRO94/laravel-access-screen) package.
108+
Alternatively, you can disable the package in production environments.
83109

84110
### Restrict Access with Middleware
85111

86-
Modify your `routes/web.php` to apply authentication:
112+
Modify your `config/mail-viewer.php` to apply authorization:
87113

88114
```php
89115
'middleware' => ['web', 'can:viewMailLogs'],
90116
```
91117

118+
> **Note:** `viewMailLogs` is just an example ability you can register via Laravel’s [Authorization Gate](https://laravel.com/docs/authorization#writing-gates).
119+
> This ability is not included in the package.
120+
92121
You can also limit access by IP address in `App\Http\Middleware\RestrictMailViewerAccess.php`:
93122

94123
```php
@@ -113,14 +142,38 @@ class RestrictMailViewerAccess
113142
Apply it in config:
114143

115144
```php
116-
117145
'middleware' => ['web', RestrictMailViewerAccess::class],
118146
```
119147

120148
Now, only authorized users or allowed IPs can access the mail viewer.
121149

122150
---
123151

152+
### Disable package in production mode
153+
#### Disable auto-discovery:
154+
```json
155+
"extra": {
156+
"laravel": {
157+
"dont-discover": [
158+
"masterro/laravel-mail-viewer"
159+
]
160+
}
161+
},
162+
```
163+
164+
#### Register package for non-production environments
165+
In your application's `ServiceProvider`
166+
```php
167+
use MasterRO\MailViewer\Providers\MailViewerServiceProvider;
168+
169+
public function register(): void
170+
{
171+
if (!$this->app->environment('production')) {
172+
$this->app->register(MailViewerServiceProvider::class);
173+
}
174+
}
175+
```
176+
124177
## License
125178

126179
This package is open-source software licensed under the [MIT license](LICENSE).

0 commit comments

Comments
 (0)