2017 © Pedro Peláez
 

library mailersaver

Override helper Mailer from laravel to hook the sender

image

distilleries/mailersaver

Override helper Mailer from laravel to hook the sender

  • Tuesday, December 27, 2016
  • by Kezho
  • Repository
  • 3 Watchers
  • 0 Stars
  • 3,067 Installations
  • HTML
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 19 Versions
  • 1 % Grown

The README.md

Scrutinizer Code Quality Code Coverage Build Status Total Downloads Latest Stable Version License, (*1)

Laravel 5 MailerSaver

Mailer saver extend the laravel 5 mailer., (*2)

  • Add the possibility to override the to,cc,bcc of your mail without modify your implementation.
  • Add the possibility to get your template mail, subject, cc, bcc and type from a model.

Table of contents

  1. Installation
  2. Config file
  3. View
  4. Send an email

Installation

Add on your composer.json, (*3)

``` json "require": { "distilleries/mailersaver": "2.*", }, (*4)


run `composer update`. Add Service provider to `config/app.php`: ``` php 'providers' => [ // ... Distilleries\MailerSaver\MailerSaverServiceProvider::class, Wpb\String_Blade_Compiler\ViewServiceProvider::class, ],

And Facade (also in config/app.php) replace the laravel facade Mail, (*5)

``` php 'aliases' => [ // ... 'Mail' => 'Distilleries\MailerSaver\Facades\Mail', ], (*6)


You need to provide a model of data, simply add on your register method a new instance of your model in your `app/Providers/AppServiceProvider.php`: ``` php public function register() { $this->app->singleton('Distilleries\MailerSaver\Contracts\MailModelContract', function ($app) { return new App\Email; }); }

In this case I return a Email model instance. This model just implement the contract Distilleries\MailerSaver\Contracts\MailModelContract., (*7)

To Publish the model:, (*8)

php artisan vendor:publish --provider="Distilleries\MailerSaver\MailerSaverServiceProvider" --tag="models"

To Publish the migration:, (*9)

php artisan vendor:publish --provider="Distilleries\MailerSaver\MailerSaverServiceProvider" --tag="migrations"

Config file

You can publish the config file with the command line:, (*10)

php artisan vendor:publish --provider="Distilleries\MailerSaver\MailerSaverServiceProvider"
    return [
        'template' => 'mailersaver::default',
        'override' => [
            'enabled' => env('MAILERSAVER_ENABLED', false),
            'to' => env('MAILERSAVER_TO', 'default1@mailto.com,default2@mailto.com'),
            'cc' => env('MAILERSAVER_CC', ''),
            'bcc' => env('MAILERSAVER_BCC', ''),
        ],
    ];
Field Description
template Global template when you put the content of your mail.
override An array with all the config to hoock the mail send.
enabled Enable the override of the mail. If in true that send the email with the to, cc, bcc
to Use to send an email when the override parameter is set to true
cc Use to send an email when the override parameter is set to true
bcc Use to send an email when the override parameter is set to true

View

To override the view you can give a new template on the configuration or modify the current one. Before modify it you have to publish it:, (*11)

php artisan vendor:publish --provider="Distilleries\MailerSaver\MailerSaverServiceProvider" --tag="views"

Send an email

It's exactly the same than the laravel mailer., (*12)

Example:, (*13)

Mail::send('emails.welcome', ['key' => 'value'], function ($message) {
    $message->to('foo@example.com', 'John Smith')->subject('Welcome!');
});

If the override is set to true email is send to another to email address., (*14)

Troubleshooting

If composer update --require-dev refuse to install, remove illuminate/* from vendor before the install or just remove vendor and start fresh., (*15)

The Versions

30/04 2015

1.1.2

1.1.2.0

Mailer saver extend the laravel 5 mailer. Add the possibility to override the to,cc,bcc of your mail without modify your implementation. Add the possibility to get your template mail, subject, cc, bcc and type from a model.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

30/04 2015

2.1.1

2.1.1.0

Mailer saver extend the laravel 5 mailer. Add the possibility to override the to,cc,bcc of your mail without modify your implementation. Add the possibility to get your template mail, subject, cc, bcc and type from a model.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

13/03 2015

dev-release/laravel-4

dev-release/laravel-4

Override helper Mailer from laravel to hock the sender

  Sources   Download

MIT

The Requires

 

by Maxime Francois

13/03 2015

1.1.1

1.1.1.0

Override helper Mailer from laravel to hock the sender

  Sources   Download

MIT

The Requires

 

by Maxime Francois

13/03 2015

1.1.0

1.1.0.0

Override helper Mailer from laravel to hock the sender

  Sources   Download

MIT

The Requires

 

by Maxime Francois

19/02 2015

2.0.2

2.0.2.0

Override helper Mailer from laravel to hock the sender

  Sources   Download

MIT

The Requires

 

by Maxime Francois

19/02 2015

2.0.1

2.0.1.0

Override helper Mailer from laravel to hock the sender

  Sources   Download

MIT

The Requires

 

by Maxime Francois

18/02 2015

2.0.0

2.0.0.0

Override helper Mailer from laravel to hock the sender

  Sources   Download

MIT

The Requires

 

by Maxime Francois

16/02 2015

1.0.1

1.0.1.0

Override helper Mailer from laravel to hock the sender

  Sources   Download

MIT

The Requires

 

by Maxime Francois

16/02 2015

1.0.0

1.0.0.0

Override helper Mailer from laravel to hock the sender

  Sources   Download

MIT

The Requires

 

by Maxime Francois