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

serpapi logo
SerpApi

The Web Search API for Your LLM and AI Applications

Visit SerpApi

The latest

View all →
Laravel Image Responses: Serve Resized Images From Routes image

Laravel Image Responses: Serve Resized Images From Routes

Read article
Pause All Laravel Queues During a Deploy image

Pause All Laravel Queues During a Deploy

Read article
Laravel Terminal UI for the artisan dev Command image

Laravel Terminal UI for the artisan dev Command

Read article
Pause All Queues and a New artisan dev UI in Laravel 13.25 image

Pause All Queues and a New artisan dev UI in Laravel 13.25

Read article
Laravel monitoring that doesn't bill you by your traffic image

Laravel monitoring that doesn't bill you by your traffic

Read article
Mock PHP Classes in Tests With the Double Library image

Mock PHP Classes in Tests With the Double Library

Read article