cyber-duck/laravel-alternative-mailer

Allow Laravel to send emails through two different mail configurations.

1.0.2 2016-06-12 17:52 UTC

README

Build Status Latest Stable Version Total Downloads License

This package allows a Laravel 5 application to send emails through two different mail configurations. This package has been adapted from illuminate/mail by Taylor Otwell.

Author: Simone Todaro

Install

Require this package with composer:

composer require cyber-duck/laravel-alternative-mailer:~1.0.2

After updating composer, add the ServiceProvider to the providers array in config/app.php

'providers' => array(
    ...
    'Cyberduck\Mail\MailServiceProvider'
)

And add an alias in config/app.php:

'aliases' => array(
    'Mail2' => 'Cyberduck\Mail\Facades\Mail',
)

Copy the package config to your local config with the publish command:

php artisan vendor:publish --provider="Cyberduck\Mail\MailServiceProvider"

Finally, set up your configuration in config/mail2.php

Usage

To send an email with the alternative configuration, use the Mail2 facade with the same syntax of the Mail facade.

\Mail2::send('emails.reminder', ['user' => $user], function ($m) use ($user) {
    $m->from('hello@app.com', 'Your Application');
    $m->to($user->email, $user->name);
    $m->subject('Your Reminder!');
});