News

Automatically Provide an Online Version of Mailables

Published
Automatically Provide an Online Version of Mailables image

Wagonwheel is a Laravel package by Sam Carré that provides an online version of your Laravel emails to users. It uses Laravel’s built-in signed URLs to create a URL for the online version, which is secured and makes it difficult to guess the URL.

It works by adding the SaveForOnlineViewing trait to any of your mailables. The readme provides the following example of a mailable:

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Sammyjo20\Wagonwheel\Concerns\SaveForOnlineViewing;
 
class BookingConfirmed extends Mailable
{
use Queueable, SerializesModels, SaveForOnlineViewing;
 
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject('Booking Confirmed')
->markdown('emails.bookings.confirmed');
}
}

At the time of writing, you can customize the placement of the component in the email and the message expiry time that determines how long Wagonwheel should keep the online version. You can also publicize the package’s views if you need to customize the look and feel.

You can learn more about this package on GitHub.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Filed in

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article