Offer an online version of your Laravel emails to users.

Last update: Aug 6, 2022

Wagonwheel

This is was a collaborative project with Ryan Chandler. Please consider supporting him for the hard work he put into this package!

Help support the maintenance of this package by buying me a coffee.

Wagonwheel

Offer an online version of your Laravel emails to users.

Latest Stable Version Total Downloads License

  • Uses Laravel's built-in temporary signed URLs to create the URL for the online version. This means it's secured by your app's encryption key, as well as making it difficult to guess.

  • Highly customisable.

  • Easy to install.

  • Supports Laravel 8

Installation

  1. Install Wagonwheel using composer with the command below:
composer require sammyjo20/wagonwheel
  1. Publish the migrations
php artisan vendor:publish --tag=wagonwheel-migrations
  1. Run the migrations
php artisan migrate
  1. Add the "SaveForOnlineViewing" trait to any of your Mailables.
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');
    }
}

Configuration

If you would like to customise how Wagonwheel works. Run the following command to publish Wagonwheel's configuration file.

php artisan vendor:publish --tag=wagonwheel-config

component_placement - This configuration variable defines if the banner should be rendered at the start of the email content or at the end of the email content. The available values are start and end.

message_expires_in_days - This configuration variable defines how long Wagonwheel should keep the online version of an email in days. If you would like the online version of your emails to never expire, set this to 0. The default is 30 days.

Customisation

If you would like to customise how the banner looks inside the email, just publish Wagonwheel's views with the following command.

php artisan vendor:publish --tag=wagonwheel-views

Testing

Run all tests

composer test

Run a specific test

composer test-f [name of test method]

Thanks

  • Ryan Chandler (@ryangjchandler) helped out massively with some great code improvements and overall making Wagonwheel better!
  • Gareth Thompson (@cssgareth) helped out with coming up with a cool name!

GitHub

https://github.com/Sammyjo20/Wagonwheel
Comments
  • 1. Added NL locale, also added tests for locale

    This PR adds the Dutch translations for Wagonwheel.

    I have also included some basic locale tests to make sure these are being pulled in correctly.

    @ryangjchandler or @Jhnbrn90 do you guys mind having a quick look over the tests I have created please? (If you get a moment) I'm still relatively new to testing and not sure if I've done it the best way possible!

    Reviewed by Sammyjo20 at 2020-12-02 22:37
  • 2. Add GitHub Action workflow for CI

    What has been done

    • Added GitHub workflow file to run phpunit for every push to master and every PR to the master branch.

    This will ensure the test suite is green before merging new code.

    Todo

    • @Sammyjo20, if you're open to add a codestyle checker as well I was thinking about using the symplify/easy-coding-standard. This codestyle would then also run as part of this GitHub Actions CI. We could also add a Git Hook to make sure newly comitted code adheres to the style and phpunit tests are passing. Let me know what you think that. If you like that idea, I can add that in a next PR.
    Reviewed by Jhnbrn90 at 2020-11-30 05:50
  • 3. Add initial test setup

    As discussed in #3, this PR adds:

    • Orchestra Testbench
    • PHPUnit (+ configuration)
    • Model factory for OnlineMailable model
    • Basic TestCase.php
    • Composer script as a shortcut to run the tests
    Reviewed by Jhnbrn90 at 2020-10-13 06:54
  • 4. Adding tests

    Dear @Sammyjo20

    I would like to add some tests for your package and I see that you want to support Laravel 7 and 8. To be able to use model factories in these tests I suggest we make use of the legacy factories, as described in the readme of Orchestra Testbench.

    Alternatively, the repository could be split up in a version that supports up to Laravel 7 and one that supports Laravel 8 and beyond.

    With your approval I'd like to submit a PR these days to add some tests using the legacy model factories approach.

    What do you think would be best?

    Reviewed by Jhnbrn90 at 2020-10-10 20:21
  • 5. Support for Dutch language

    To support Dutch language (which is 'nl'), add the following please ^^

    <?php
    
    return [
        'message' => 'Is de e-mail niet goed leesbaar?',
        'link'    => 'Bekijk het in de browser',
    ];
    Reviewed by RoodFruit at 2020-12-02 12:01
  • 6. Allow mailables to be stored online for an indefinite amount of time

    Introduction

    This PR allows mailables to never expire, in addition to the currently existing configuration options to specify an amount in days before the mailable expires.

    <?php
    
    return [
        /*
         * ...
         * To store indefinitely, set this value to: 0.
         */
        'message_expires_in_days' => 0,
    ];
    

    What has been done

    In this PR there are a lot of files changed, since I took an opportunity to refactor some logic around:

    • the dertermination of an expiry date
    • the generation of the signed route URL

    I'll list the updates I made below:

    • Added explanation (doc block) to store mailables indefinitely in config/wagonwheel.php
    • Added unit tests for the OnlineMailable model
      • Test that a mailable can have a null expiration date
    • Added test to DeleteExpiredMailables command to assure it doesn't delete OnlineMailables with a null expiration date
    • Extract logic for determining the expiration date to the OnlineMailable model in a getExpirationDate() method.
    • Extract logic for building signed route URL's to the OnlineMailable model itself in a getSignedUrl method.
      • This method returns a temporarySignedRoute when a mailable has a expiration date
      • It returns a signedRoute (which doesn't expire) when a mailable does not have an expiration date
    • Removed redundant UrlHelper class
    • Updated code to make use of the methods on the OnlineMailable model
    • Added feature test for the package, testing that:
      • sent e-mails have an online variant when the SaveForOnlineViewing trait is used
      • mailables with expiration date URL's are valid until the expiration date
      • mailables without expiration date are always accessible

    How to test

    You can test the functionality within this PR by:

    • checking out this branch
    • adding the package to a Laravel package (locally) (instructions)
    • add the SaveForOnlineViewing trait to a certain Laravel Mailable
    • publish the packages configuration php artisan vendor:publish --tag=wagonwheel-config
    • change the 'message_expires_in_days' value to 0.
    • send the e-mail from the Laravel app (using the log driver or mailtrap of mailhog or ...)
    • assert that the database has an expire_at column of null for the mailable in the online_mailables table
    • run the command php artisan wagonwheel:delete-expired-mailables
    • assert that the command does not delete this mailable
    • assert that you can view this e-mail in the browser, by using the generated signed URL (check the logs / mailtrap / mailhog /...)

    Notes

    It might be well possible that there are other refactors to be made, but I tried to limit refactoring the code to the scope of allowing indefinite availability of online mailables.

    Reviewed by Jhnbrn90 at 2020-10-13 19:01
  • 7. Fix migration error

    Hi, First of all, I would like to thank you for your great work @Sammyjo20 :+1: I tried to install your package, but I encountered a slight problem during the migration of the table. So I decided to propose a simple improvement, so that everyone can install this package without encountering any error from the beginning.

    My problem was this one:

    SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'expires_at' (SQL: create table `online_mailables` (`id` bigint unsigned not null auto_increment primary key, `uuid` char(36) not null, `created_at` timestamp null, `updated_at` timestamp null, `expires_at` timestamp not null, `content` blob not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
    

    Just set "expires_at" nullable fix it.

    Thanks again for your work, See ya!

    Reviewed by Simon-BEE at 2020-10-11 15:36
  • 8. Absolute/Relative path for css styles

    Hi!

    I think you got a problem with the code regarding absolute/relative paths. I'm using for example fedeisas/laravel-mail-css-inliner in combination with your package. This one converts my added css from the public folder into inline styles (e.g: "").

    Because the url used to show the mailable is mail/view-online... it fails to load the css file. I've solved the issue by using mix.

    mix.sass('resources/scss/app.scss', 'public/css') .copy('public/css', 'public/mail/view-online/css');

    Maybe you should include this into the documentation as a known issue or try to solve it :)

    Reviewed by CatalinBratu7 at 2020-10-16 15:33
  • 9. Allow mailables to be stored online without appending url in mailables

    I was wondering what you are thinking about this.

    The easiest way is publish the view and empty it.

    But maybe it is better to make it configurable? Something like wagonwheel.component_placement = none. Or a different key with true/false value.

    Let me know and I will start working an a pull request.

    Reviewed by ricklambrechts at 2020-10-14 23:10
  • 10. Add tests for DeleteExpiredMailable Command

    This PR adds a test for the DeleteExpiredMailable command and asserts that it can succesfully delete expired mailables, but does not delete non-expired mailables.

    @Sammyjo20 in my next PR, I'll write a test for the feature I'm working on, to allow users to store mailables indefinitely.

    This PR is dependent on #6 (which should be merged first).

    Reviewed by Jhnbrn90 at 2020-10-13 06:56
Store outgoing emails in Laravel
Store outgoing emails in Laravel

Record and view all sent emails Watch a video walkthrough https://www.youtube.com/watch?v=Oj_OF5n4l4k&feature=youtu.be Documentation and install instr

Aug 7, 2022
Mail Web is a Laravel package which catches emails locally for debugging
 Mail Web is a Laravel package which catches emails locally for debugging

Mail Web is a Laravel package which catches emails locally for debugging Installation Use the package manager composer to install Mail Web. composer r

Jul 27, 2022
Send beautiful HTML emails with Laravel
Send beautiful HTML emails with Laravel

Beautymail for Laravel Beautymail makes it super easy to send beautiful responsive HTML emails. It's made for things like: Welcome emails Password rem

Aug 13, 2022
CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very usefull when you're sending emails.

CssToInlineStyles class Installation CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline style

Aug 11, 2022
Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)

PHP IMAP Initially released in December 2012, the PHP IMAP Mailbox is a powerful and open source library to connect to a mailbox by POP3, IMAP and NNT

Aug 8, 2022
The Mailer component helps sending emails

Mailer Component The Mailer component helps sending emails. Getting Started $ composer require symfony/mailer use Symfony\Component\Mailer\Transport;

Aug 8, 2022
Allows you to archive old emails from one Gmail mailbox to another Gmail mailbox

Gmail Archiver L'application Gmail archiver permet de déplacer automatiquement tous les vieux mails d'une boite Gmail vers une autre boite Gmail (ou é

Jan 27, 2022
Queue, preview and and send emails stored in the database.

Codeigniter4 email queue Queue, preview and and send emails stored in the database. This package provides an interface for creating emails on the fly

Apr 12, 2022
This application (class) does the sending of emails used in the phpmailer library

emailsender - PHP Notification library via email using phpMailer This library has the function of sending email using the phpmailer library. Doing thi

Feb 9, 2022
Library for using online Email providers

Stampie Stampie have been moved to the "Flint" organization in order to get a better collaborative flow. Stampie is a simple API Wrapper for different

Oct 7, 2020
Library for using online Email providers

Stampie Stampie is a simple API Wrapper for different email providers such as Postmark and SendGrid. It is very easy to use and to integrate into your

Jun 16, 2022
Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app.

Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app. This enables your app to not only respond to new emails but also allows it to read and parse existing mails and much more.

Aug 10, 2022
Provides a clean and simple way to configure the WordPress-bundled PHPMailer library, allowing you to quickly get started sending mail through a local or cloud based service of your choice

WP PHPMailer provides a clean and simple way to configure the WordPress-bundled PHPMailer library, allowing you to quickly get started sending mail through a local or cloud based service of your choice.

Jul 21, 2022
Simple mail sending by PHPMailer and Create your local system.

Simple mail sending by PHPMailer and Create your local system. Send mail zero of cost and also send Attachment like Photo, pdf and multiple files. You should be create a login and verify two steps authentication like OTP, verifications ?? link. PHPMailer make your dreams project eassy and simple also free of cost.

Dec 8, 2021
Laravel Mail Credentials switcher for Budget Laravel Applications

Laravel Mail Switcher Laravel Mail Credentials Switcher is a library which helps you to: Manage your Mail Service Credentials Configure the Laravel's

Aug 6, 2022
Laravel Mail Catcher Driver
 Laravel Mail Catcher Driver

Laravel Mail Catcher Driver This package include a new mailbase driver which will catch all the sent emails and save it to the database. It then expos

Jul 12, 2022
MailEclipse - Laravel Mailable Editor!
MailEclipse - Laravel Mailable Editor!

MailEclipse is a mailable editor package for your Laravel applications to create and manage mailables using a web UI.

Aug 10, 2022
Disposable email address validator for Laravel

Laravel Disposable Email Adds a validator to Laravel for checking whether a given email address isn't originating from disposable email services such

Aug 10, 2022
A testing package for intercepting mail sent from Laravel
A testing package for intercepting mail sent from Laravel

Laravel Mail Intercept A testing package for intercepting mail sent from Laravel This testing suite intercepts Laravel Mail just before they are sent

Jul 20, 2022