iyba / beautymail
v2.0.1
2017-12-03 07:50 UTC
Requires
- php: >=5.4.0
- illuminate/support: 4.*|5.*
- pelago/emogrifier: @dev
README
Beautymail可以让您轻松发送漂亮的响应式HTML电子邮件。适用于如下场景:
- 欢迎邮件
- 密码提醒
- 发票
- 数据导出
如果您使用Laravel 4,请使用1.x分支。
模板
市面上有大量的精美HTML电子邮件模板。Campaign Monitor和Mailchimp已经发布了数百个免费模板。将模板适配到Beautymail非常简单。如果您做了适配,请发送PR。
Campaign Monitor的Widgets
Stamplia的Minty
Sunny
安装
通过运行以下命令将包添加到您的composer.json
composer require snowfire/beautymail dev-master
安装完成后,将其添加到config/app.php中的提供者列表
Snowfire\Beautymail\BeautymailServiceProvider::class,
将资源发布到您的公开目录
php artisan vendor:publish --provider="Snowfire\Beautymail\BeautymailServiceProvider"
发送您的第一封美丽邮件
将以下内容添加到您的routes.php
Route::get('/test', function() { $beautymail = app()->make(Snowfire\Beautymail\Beautymail::class); $beautymail->send('emails.welcome', [], function($message) { $message ->from('bar@example.com') ->to('foo@example.com', 'John Smith') ->subject('Welcome!'); }); });
现在创建resources/views/emails/welcome.blade.php
@extends('beautymail::templates.widgets')
@section('content')
@include('beautymail::templates.widgets.articleStart')
<h4 class="secondary"><strong>Hello World</strong></h4>
<p>This is a test</p>
@include('beautymail::templates.widgets.articleEnd')
@include('beautymail::templates.widgets.newfeatureStart')
<h4 class="secondary"><strong>Hello World again</strong></h4>
<p>This is another test</p>
@include('beautymail::templates.widgets.newfeatureEnd')
@stop
就这样!
选项
模板: Widgets
要更改不同部分的颜色,传递一个颜色变量
@include('beautymail::templates.widgets.articleStart', ['color' => '#0000FF'])
Minty模板示例
@extends('beautymail::templates.minty')
@section('content')
@include('beautymail::templates.minty.contentStart')
<tr>
<td class="title">
Welcome Steve
</td>
</tr>
<tr>
<td width="100%" height="10"></td>
</tr>
<tr>
<td class="paragraph">
This is a paragraph text
</td>
</tr>
<tr>
<td width="100%" height="25"></td>
</tr>
<tr>
<td class="title">
This is a heading
</td>
</tr>
<tr>
<td width="100%" height="10"></td>
</tr>
<tr>
<td class="paragraph">
More paragraph text.
</td>
</tr>
<tr>
<td width="100%" height="25"></td>
</tr>
<tr>
<td>
@include('beautymail::templates.minty.button', ['text' => 'Sign in', 'link' => '#'])
</td>
</tr>
<tr>
<td width="100%" height="25"></td>
</tr>
@include('beautymail::templates.minty.contentEnd')
@stop
Ark模板示例
@extends('beautymail::templates.ark')
@section('content')
@include('beautymail::templates.ark.heading', [
'heading' => 'Hello World!',
'level' => 'h1'
])
@include('beautymail::templates.ark.contentStart')
<h4 class="secondary"><strong>Hello World</strong></h4>
<p>This is a test</p>
@include('beautymail::templates.ark.contentEnd')
@include('beautymail::templates.ark.heading', [
'heading' => 'Another headline',
'level' => 'h2'
])
@include('beautymail::templates.ark.contentStart')
<h4 class="secondary"><strong>Hello World again</strong></h4>
<p>This is another test</p>
@include('beautymail::templates.ark.contentEnd')
@stop
Sunny模板示例
@extends('beautymail::templates.sunny')
@section('content')
@include ('beautymail::templates.sunny.heading' , [
'heading' => 'Hello!',
'level' => 'h1',
])
@include('beautymail::templates.sunny.contentStart')
<p>Today will be a great day!</p>
@include('beautymail::templates.sunny.contentEnd')
@include('beautymail::templates.sunny.button', [
'title' => 'Click me',
'link' => 'http://google.com'
])
@stop


