Blog Detail

11

Aug
Catch All Sent Email & Show them on Laravel Application View cover image

arrow_back Catch All Sent Email & Show them on Laravel Application View

Laravel Web Mailer package contains a web mailer that will catch all the sent emails and show them on an application view in Laravel. Then, you can view it by visiting the route /web-inbox. The emails will be stored as a file in the storage folder.

Requirements

This package requires PHP 8.1 and Laravel 9. If you need compatibility with older versions, check the alternatives section.

Installation

You can install this package via composer:

composer require creagia/laravel-web-mailer

After that, open your config/mail.php file and add the web mailer entry in the mailers configuration array.

'mailers' => [
    // ...
    'web' => [
        'transport' => 'web',
    ],
],

Finally, you can enable the web mailer setting the defined mailer in your .env file:

MAIL_MAILER=web

We recommend you publish the configuration file to be able to perform some customizations

php artisan vendor:publish --tag="web-mailer-config"

Inbox URL

The default URL to view the emails is /web-inbox. You can change it, by adding the below entry to your .env file:

WEB_MAILER_ROUTE_PREFIX="your-custom-url"

Route protection

By default, the inbox URL is authorized for everybody who has the link. If you need to add some protection, you can modify the middleware array on the config/web-mailer.php file.

Delete all stored emails

php artisan laravel-web-mailer:clear-all

Delete stored emails older than N days

php artisan laravel-web-mailer:cleanup

You can run or schedule the command laravel-web-mailer:cleanup to delete the emails older than N days. By default, it will delete emails older than 7 days. You can customize the number of days by changing the delete_emails_older_than_days parameter on the config/web-mailer.php file.

Note

If you have an awesome idea then Codebrisk is always here to convert your ideas into reality. Our team of expert developers is trained in Laravel custom web app development, CRM software development, and e-commerce app development. We run with a superior level of agility and an immense Laravel ecosystem to customize the software for your business. For further assistance, please contact us or you can launch a project with us.

Published at : 11-08-2022

Author : Rizwan Aslam
AUTHOR
Rizwan Aslam

I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.

Launch your project

Launch project