preshetin/mail-sender
Composer 安装命令:
composer require preshetin/mail-sender
包简介
Mail block that sends email by template
README 文档
README
Mail block that sends email by template for Laravel 5.3 / Laraflock Dashboard
Install
- Require in composer:
composer require preshetin/mail-sender:dev-master
- Then register in
config/app.php
providers' => [
...
Preshetin\MailSender\MailSenderServiceProvider::class,
];
- Run migrations to create
mail_logs&mail_templatestables:
php artisan migrate
- Add
MailableEntityinterface &MailSenderTraittrait in any Eloquent model:
use Preshetin\MailSender\MailSenderTrait;
use Preshetin\MailSender\Model\MailableEntity;
class Order extends Model implements MailableEntity
{
use MailSenderTrait;
// ...
}
MailableEntityinterface will require you to add a couple of methods:
This is where email sends TO:
public function getEmail()
{
return $this->user->email;
}
And getMailTemplateReplacements which gets values for mail template variables:
public function getMailTemplateReplacements()
{
return [
'[ORDER_ID]' => $this->id,
'[NAME]' => $this->user->name,
...
];
}
That's it! Now you may insert Blade templates and get mail send functionality!
Usage
Add in blade templates:
@include('mail-sender::partials.mail', ['mailable_entity' => $order])
Also, you may add to your sidebar:
@include('mail-sender::partials.sidebar')
Configuration
You may php artisan vendor:publish config mail-sender.php. There you may ajust a view for emails:
'mail_view' => 'emails.your_custom_view',
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-07-26