Automatically Provide an Online Version of Mailables

Automatically Provide an Online Version of Mailables

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.

Filed in: News

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior Laravel Developer
Remote
EC Pro
Senior Full-Stack Engineer
[REMOTE: USA Only] All Other Applications Will be Rejected Immediately"
Curricula
Senior Full Stack PHP Developer
Canada
Motto Design Studio
Software Engineer
Remote, USA Only
Grow Progress
Lead Backend PHP Developer
Hamburg, Deutschland
ABOUT YOU GmbH