hazzard/mail
在Laravel之外使用Illuminate Mail。
2.0.1
2015-08-03 16:29 UTC
Requires
- php: >=5.4
- illuminate/config: 5.0.*|5.1.*
- illuminate/mail: 5.0.*|5.1.*
This package is auto-updated.
Last update: 2024-09-14 04:26:32 UTC
README
安装
composer require illuminate/config
composer require illuminate/mail
composer require hazzard/mail
composer require guzzlehttp/guzzle
(用于Mailgun和Mandrill,必需)
使用
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();
使用邮件发送器
Mail::send('emails.welcome', ['key' => 'value'], function ($message) {
$message->to('foo@example.com', 'John Smith')->subject('Welcome!');
});
其余部分与Laravel相同。
提供自定义视图工厂
要提供自定义视图工厂,需要在容器中注册一个view
绑定。
视图工厂必须实现Illuminate\Contracts\View\Factory
接口和视图Illuminate\Contracts\View\View
接口(或者至少要有render
方法)。
$container['view'] = new CustomViewFactory();