snowfire/beautymail
Composer 安装命令:
composer require snowfire/beautymail
包简介
Send beautiful html emails with Laravel
README 文档
README
Beautymail makes it super easy to send beautiful responsive HTML emails. It's made for things like:
- Welcome emails
- Password reminders
- Invoices
- Data exports
Index:
Templates
There are tons of great looking HTML email templates out there. Campaign Monitor and Mailchimp has released hundreds for free. It is pretty simple to adapt a template to Beautymail.
Widgets by Campaign Monitor:
Minty by Stamplia:
Sunny
Installation
Add the package to your composer.json by running:
composer require snowfire/beautymail
Configure your settings such as logo url and social links in config/beautymail.php
Send your first Beauty mail
Add this to your routes/web.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!'); }); });
Now create 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
That's it!
Options
Template: Widgets
To change colours for the different segments, pass a colour variable:
@include('beautymail::templates.widgets.articleStart', ['color' => '#0000FF'])
Minty template example
@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 template example
@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 template example
@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
Lumen support
In order to get this working on Lumen follow the installation instructions except for the artisan vendor:publish command, since Lumen does not provide this command. Instead you have to copy the assets folder from vendor/snowfire/beautymail/public/ to the public folder in your Lumen project manually.
Make sure to also put the beautymail.php config file in the config folder (default available in src/config/settings.php)
Enable mailing in Lumen
After this you will need to install and configure illuminate/mailer with:
composer require illuminate/mail
and add this to your bootstrap/app.php:
$app->withFacades();
$app->register(App\Providers\AppServiceProvider::class);
See this blog post for more details and how to use different mail libraries in lumen:
Configure Beautymail classes and configuration parameters
In order to get Beautymail working on Lumen you need to add the following to your bootstrap/app.php in order to resolve missing config files, parameters and classes (before you register BeautymailServiceProvider):
// Provide required path variables
$app->instance('path.config', env("STORAGE_DIR", app()->basePath()) . DIRECTORY_SEPARATOR . 'config');
$app->instance('path.public', env("STORAGE_DIR", app()->basePath()) . DIRECTORY_SEPARATOR . 'public');
// Enable config for beautymail
$app->configure('beautymail');
// Provide class alliases to resolve Request and Config
class_alias(\Illuminate\Support\Facades\Request::class, "\Request");
class_alias(\Illuminate\Support\Facades\Config::class, "\Config");
Start using Beautymail
Congratulations, you can know start using Beautymail in Lumen. See: Send your first Beauty mail on what to do next.
snowfire/beautymail 适用场景与选型建议
snowfire/beautymail 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 753.73k 次下载、GitHub Stars 达 1.31k, 最近一次更新时间为 2014 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「html」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 snowfire/beautymail 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 snowfire/beautymail 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 snowfire/beautymail 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
HTML and form generation
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
A modern HTML DOM parser for PHP using DOMDocument and Symfony CssSelector.
Reusable utilities library for Lacus Solutions' packages (type description, HTML escaping, random sequences)
统计信息
- 总下载量: 753.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1318
- 点击次数: 15
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-07-27


