Simple transactional email classes/templates for Laravel 5 mailables

Overview

Tuxedo

Version License Total Downloads Build Status

Tuxedo is an easy way to send transactional emails with Laravel's Mail classes, with the templates already done for you.

Contents

Installation

  1. Run the following command:
$ composer require tomirons/tuxedo
  1. Open your config/app.php and add the following class to your providers array:
TomIrons\Tuxedo\TuxedoServiceProvider::class
  1. (Optional) If you would like to edit the templates, run the following command to publish them
php artisan vendor:publish --provider=TomIrons\Tuxedo\TuxedoServiceProvider

Classes

There are currently 3 different types of classes you can extend. ActionMailable, AlertMailable, and InvoiceMailable, and each have their own special properties and methods.

Global Methods

These methods are available in ALL classes.

  • greeting($greeting) - Sets the greeting for the message.
  • salutation($salutation) - Sets the salutation for the message.
  • line($line) - Add a line of text to the message.

ActionMailable

Methods

  • color($color) - Sets the color of the button. Available options are blue, green, and red.
  • action($text, $url) - Sets the button text and url.
  • success() - Sets the button color to green.
  • error() - Sets the button color to red.
  • info() - Sets the button color to blue.

Example

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use TomIrons\Tuxedo\Mailables\ActionMailable;

class ActionMail extends ActionMailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->greeting('Hello!')
                    ->line('Some line of text to tell you what exactly is going on.')
                    ->action('Click here to do something fun', url('/'))
                    ->line('Some other information to be displayed after the button.')
                    ->salutation('Regards, Example App');
    }
}

Screenshot

Action

AlertMailable

Methods

  • info() - Sets the type of the alert to info.
  • warning() - Sets the type of the alert to warning.
  • success() - Sets the type of the alert to success.
  • error() - Sets the type of the alert to error.
  • type($type) - Sets the type of alert, options are info, success, warning, and error.
  • message($message) - Sets the message to display in the alert.

Example

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use TomIrons\Tuxedo\Mailables\AlertMailable;

class AlertMail extends AlertMailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->greeting('Hello!')
                    ->info()
                    ->message('Some text goes here to inform the user')
                    ->line('Some line of text to tell you what exactly is going on.')
                    ->salutation('Regards, Example App');
    }
}

Screenshot

Alert

InvoiceMailable

Properties

  • $keys|array - Set which keys to use when looking for an item's name and price.

Methods

  • id($id) - Sets the invoice ID.
  • date($date) - Sets the date to display at the top of the invoice table.
  • due($date) - Sets the due date of the invoice.
  • items($items) - Add an list of items to the invoice. Acceptable variable types are Collection and array.
  • calculate($taxPercent, $shipping) - Calculates the tax and final total, MUST be called after items have been added.

Example

<?php

namespace App\Mail;

use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use TomIrons\Tuxedo\Mailables\InvoiceMailable;

class InvoiceMail extends InvoiceMailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->id(123456)
                    ->greeting('Hi John Doe!')
                    ->date(Carbon::now()->format('l, M j Y \a\t g:i a'))
                    ->due(Carbon::now()->addDays(7)->format('l, M j Y \a\t g:i a'))
                    ->action('Click me to pay', url('/'))
                    ->items([
                        ['product_name' => 'Example Product', 'product_price' => 123.99],
                        ['product_name' => 'Second Product', 'product_price' => 321.99]
                    ])
                    ->calculate(3, 15)
                    ->salutation('Regards, Example App');
    }
}

Screenshot

Invoice

License

Tuxedo is open-sourced software licensed under the MIT license

You might also like...
A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic

A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic! concepts like , Hijri Dates & Arabic strings and so on ..

Load files and classes as lazy collections in Laravel.

Lody Load files and classes as lazy collections in Laravel. Installation composer require lorisleiva/lody Usage Lody enables you to fetch all exist

Collection of the Laravel/Eloquent Model classes that allows you to get data directly from a Magento 2 database.

Laragento LAravel MAgento Micro services Magento 2 has legacy code based on abandoned Zend Framework 1 with really ugly ORM on top of outdated Zend_DB

A laravel package to attach uuid to model classes

Laravel Model UUID A simple package to generate model uuid for laravel models Installation Require the package using composer: composer require touhid

An opinioned approach to extend the laravel seed classes.

Laravel Seed Extender A highly opinioned way to work with the laravel seeder. Installation Require the package using composer: composer require touhid

Use Laravel's built-in ORM classes to query cloud resources with Steampipe.
Use Laravel's built-in ORM classes to query cloud resources with Steampipe.

Laravel Steampipe Use Laravel's built-in ORM classes to query cloud resources with Steampipe, an open source CLI to instantly query cloud APIs using S

Collection of classes you can use to standardize data formats in your Laravel application.
Collection of classes you can use to standardize data formats in your Laravel application.

Laravel Formatters This package is a collection of classes you can use to standardize data formats in your Laravel application. It uses the Service Co

A collection of classes to be extended/used in laravel apps for quick development

laraquick A collection of classes to be extended/used in laravel applications for quick development. Introduction The library contains traits with wel

🏭This package lets you create factory classes for your Laravel project.
🏭This package lets you create factory classes for your Laravel project.

Laravel Factories Reloaded 🏭 This package generates class-based model factories, which you can use instead of the ones provided by Laravel. Laravel 8

Comments
  • would be nice to have a config file where you can change the namespace of the classes

    would be nice to have a config file where you can change the namespace of the classes

    Would also be nice to have the option to publish the 3 mail classes so we can override them

    I have a situation where I need to pass custom headers to Mail::queue and I am implementing the fix here https://medium.com/@guysmilez/queuing-mailables-with-custom-headers-in-laravel-5-4-ab615f022f17

    But in order to do that I have to extend Mailable, but your classes also extend Mailable and I want to use your classes.. so now I have to copy your classes to my own codebase and change them so they extend my modified Mailable class :)

    opened by vesper8 4
  • any suggestion for logging all this mail activity?

    any suggestion for logging all this mail activity?

    Hi there! I really like your package and will start using it right away.

    I was wondering however if you have any suggestions for me, I would like to have a detailed "mail log" of all this activity.

    I am thinking of simply using https://github.com/spatie/laravel-activitylog. But I wouldn't have minded something similar to that but exclusively for tracking emails.

    I would like to created queue-able emails.. see at what time they were queued, at what time they were sent.. to whom they were sent.. and some other details. Anything like that already exist?

    opened by vesper8 1
  • Is your package only for v5.4?

    Is your package only for v5.4?

    I'm want to switch my production project to 5.4 yet, but was looking for this mailable solution but i'm using v5.3. I know that markdown is not available in my version but i just want to have MailMessage functionality on Mailable object, is that possible with your soluction?

    Best regards GP

    opened by eescalante 1
Releases(v2.0.0)
Owner
Tom Irons
Tom Irons
This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.

Laravel Verify New Email Laravel supports verifying email addresses out of the box. This package adds support for verifying new email addresses. When

Protone Media 300 Dec 30, 2022
A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

Ollie Codes 19 Jul 5, 2021
A simple artisanal command framework for creating service layer classes

Introdução Este projeto tem como objetivo fornecer alguns comandos adicionais à interface de linha de comando do Laravel para manipular a estrutura da

Eliezer Alves 15 Feb 2, 2022
Use Blade templates without the full Laravel framework

blade Use Laravel Blade templates as a standalone component without the full Laravel framework Full documentation is available at http://duncan3dc.git

Craig Duncan 138 Dec 7, 2022
API Blueprint Renderer for Laravel, customizable via Blade templates

API Blueprint Renderer for Laravel This Laravel package Blueprint Docs renders your API Blueprint. It comes with a standard theme that you can customi

Michael Schmidt-Voigt 225 Sep 16, 2022
A library for using Laravel Blade templates in WordPlate.

A library for using Laravel Blade templates in WordPress/WordPlate. Installation Require this package, with Composer, in the root directory of y

null 28 Nov 28, 2022
Vim syntax highlighting for Blade templates.

vim-blade Vim syntax highlighting for Blade templates (Laravel 4+). This plugin contributes to vim-polyglot language pack. Installation Using vim-plug

Jason Walton 194 Dec 1, 2022
Extend Kirby’s templates with a powerful layout system

Kirby Layouts plugin This plugin extends Kirby’s templates with a powerful layout system. Installation Download Download and copy this repository to /

Kirby 3 39 Dec 28, 2022
Create inline partials in your Blade templates with ease

Create inline partials in your Blade templates with ease. This package introduces a new @capture directive that allows you to capture small parts of y

Ryan Chandler 27 Dec 8, 2022
Mailing platform with templates and logs included.

MailCarrier User-friendly, API-ready mail platform with templates and logs. Design global layouts, compose your template, preview your emails and send

MailCarrier 18 Dec 14, 2022