Offer an online version of your Laravel emails to users.

Overview

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!
Comments
  • Added NL locale, also added tests for locale

    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!

    opened by Sammyjo20 6
  • Add GitHub Action workflow for CI

    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.
    opened by Jhnbrn90 6
  • Add initial test setup

    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
    opened by Jhnbrn90 3
  • Adding tests

    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?

    opened by Jhnbrn90 3
  • Support for Dutch language

    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',
    ];
    opened by RoodFruit 1
  • Allow mailables to be stored online for an indefinite amount of time

    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.

    opened by Jhnbrn90 1
  • Fix migration error

    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!

    opened by Simon-BEE 1
  • Absolute/Relative path for css styles

    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 :)

    opened by catalin-bratu 0
  • Allow mailables to be stored online without appending url in mailables

    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.

    opened by ricklambrechts 0
  • Add tests for DeleteExpiredMailable Command

    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).

    opened by Jhnbrn90 0
Releases(v2.0.1)
Owner
Sam Carré
Financial services web developer. Laravel, Livewire, Vue, TALL. 🤠
Sam Carré
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

David Carr 203 Dec 15, 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 Installation Use the package manager composer to install Mail Web. composer r

Appoly 64 Dec 24, 2022
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

null 1.1k Jan 2, 2023
Laravel mailer which will catch all the sent emails and show them on an application view.

Laravel Web Mailer This package contains a web mailer which will catch all the sent emails. Then, you can view it visiting the route /web-inbox. The e

Creagia 54 Dec 16, 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

Tijs Verkoyen 5.7k Dec 29, 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

Sergey 1.5k Jan 3, 2023
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;

Symfony 1.1k Jan 7, 2023
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 é

Arnaud Lemercier 19 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

null 3 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

Lucas Alcantara Rodrigues Volpati 1 Feb 9, 2022
A ready-to-use PHP script for sending Emails with an HTML Template will use a Gmail account as the sender and you will not need any email server. Powered by PHPMailer.

Gmail Email Sender by PHP A ready-to-use PHP script for sending Emails with an HTML Template will use a Gmail account as the sender and you will not n

Max Base 4 Oct 29, 2022
Mandrill mail driver for Laravel for version 6+

Laravel Mandrill Driver This package re-enables Mandrill driver functionality using the Mail facade in Laravel 6+. To install the package in your proj

Eng Hasan Hajjar 2 Sep 30, 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

Henrik Bjørnskov 32 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

Stampie 288 Dec 31, 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.

null 530 Jan 6, 2023
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.

Itineris Limited 61 Dec 6, 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.

SUSHIL KUMBHAR 2 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

(Seth) Phat Tran 34 Dec 24, 2022
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

Tauqeer Liaqat 94 Aug 30, 2022