Locale is in early access
The first localization platform specifically built for Laravel. Your team and translators will be able to enjoy a next-level localization workflow built for productivity.

A package to catch and show emails sent by your Laravel application

Xavier Muntané
4 August 2022

This week, we released a package called creagia/laravel-web-mailer. Often, when we work on our clients' projects, we create a pre-production environment where we test and validate new functionalities together.

Depending on the project, we are interested in validating the sent emails. We want to check out with our clients which emails are being sent, when are they sent, their recipient... Obviously, we are not interested in these emails actually being sent.

What were we using until today

Until now, we had used third-party services such as Mailtrap. This, apart from the cost, added management complexity for us, since it was not integrated into the application itself.

We had also used some open source packages. But we just couldn't find one that fit us perfectly. Because some were outdated, others lacked functionality we needed (such as viewing attachments or restricting access to certain users), ...

For this reason, we decided to create our own package, programmed using a modern stack as in all other client developments (PHP 8.1, Alpine.js and Tailwind CSS).

Package inbox screenshot

Features of the package

The package we have developed is responsible for catching all the emails sent by the Laravel application. These, unlike most existing packages, are saved in files instead of database. This way, we avoid having differences in the structure of the database between the pre-production and the production environment.

To view the emails sent, simply visit the "/web-inbox" route of the same application.

Access to pre-production servers is usually restricted. For this reason, we have left the "/web-inbox" path visible to everyone. However, if necessary, you can control its access by adding the necessary "middleware" to the package's configuration file.

You can read all the features and how to use them on the documentation page.