hazzard/mail
| Install | |
|---|---|
composer require hazzard/mail |
|
| Latest Version: | 2.0.1 |
| PHP: | >=5.4 |
| Laravel: | 5 |
| License: | MIT |
| Last Updated: | Aug 3, 2015 |
| Links: | GitHub · Packagist |
Illuminate Mail Outside Laravel
Installation
composer require illuminate/config
composer require illuminate/mail
composer require hazzard/mail
composer require guzzlehttp/guzzle (required for Mailgun and Mandrill)
Usage
use Hazzard\Mail\Mail;
use Illuminate\Container\Container;
use Illuminate\Config\Repository as Config;
// Create a container and config repository.
$app = new Container;
$app['config'] = new Config;
// Set the mail & services configuration.
$app['config']['mail'] = require 'config/mail.php';
$app['config']['services'] = require 'config/services.php';
$mail = new Mail($container);
// Set the storage path used by the views.
$mail->setViewStoragePath(_DIR__.'/path/to/views');
// Make the instance available globally via static methods (optional).
$mail->setAsGlobal();
// Create a class alias (optional).
$mail->classAlias();
Using The Mailer
Mail::send('emails.welcome', ['key' => 'value'], function ($message) {
$message->to('foo@example.com', 'John Smith')->subject('Welcome!');
});
The rest is the same as Laravel.
Providing A Custom View Factory
To provide a custom view factory register a view binding to the container.
The view factory must implement Illuminate\Contracts\View\Factory and the view Illuminate\Contracts\View\View (or at least to have a render method).
$container['view'] = new CustomViewFactory();
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 2.0.1 | >=5.4 | 5.0.*| | MIT | |
| 2.0.0 | >=5.4 | 5.0.*| | MIT | |
| 1.0.0 | >=5.3 |