Download the PHP package filippo-toso/laravel-mailog without Composer
On this page you can find all versions of the php package filippo-toso/laravel-mailog. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download filippo-toso/laravel-mailog
More information about filippo-toso/laravel-mailog
Files in filippo-toso/laravel-mailog
Package laravel-mailog
Short Description Log your emails to the database and view them in a simple web interface
License MIT
Homepage https://github.com/filippotoso/laravel-mailog
Informations about the package laravel-mailog
Laravel Mailog
This package allows you to store all your application outgoing email into a database and (optionally) view them using the integrated Web UI.
You can use it as a mail transport (no email is delivered) or as an event listener (all emails are delivered normally but also logged into the database).
Why does this exist?
Maybe you are asking yourself why I built this package when there's the log driver or services like Mailtrap, etc.
I work with a lot of institutional customers (banks, public bodies, you name it...). These customers are very picky about where their data is stored (ie. Are Mailtrap data centers in the EU? How are they secured? Who has access to them? And the list goes on, and on, and on...). This package offers a self-hosted solution that works perfectly in both test and production environments and meets their stringent requirements.
Installation
Install the package using composer:
If you want/need to customize the configuration (ie. use a different database for the logging, etc.), publish the configuration file and change it accordingly:
Publish the migrations and change them accordingly:
Then, execute the migrations:
Use it as a Mail Transport
In your config/mail.php file add the mailog mailer as shown below.
Then edit your .env file as follows:
Use it as an Event Listener
Just edit the config/mailog.php file as follows:
Access the Web UI
If you want to use the built-in web UI, you can register the routes in your web.php file.
Then you'll be able to access the UI using the /mailog/messages url.
If you want to customize the UI, you can publish the views as follows:
You can also override the FilippoToso\LaravelMailog\Http\Controllers\MessageController class and change its behaviour. For instance you could add a filter for your tenant:
Then you have to update your routes file to point to the right controller.
You can take inspiration from the FilippoToso\LaravelMailog\Support\Routes::register() method.
Overriding the Mail Transport behaviour
In the config/mailog.php file you can specify a class to use as a transport. For instance, you can override the provided MailogTransport class and add the support for tenancy as follows:
Please beware, the use of tenant('id') for identifing the tenant foreign key is just an example taken from the stancl/tenancy package. Depending on how you are implementing the tenancy, you should adapt the code as needed.
Other useful things to know
The package includes a mailog:purge-messages command. You can schedule it in the scheduler and configure its behaviour in the purge section of the config/mailog.php file
All versions of laravel-mailog with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version >=9.0
illuminate/config Version >=9.0
illuminate/mail Version >=9.0
illuminate/database Version >=9.0
illuminate/http Version >=9.0
illuminate/console Version >=9.0
illuminate/view Version >=9.0