desmond/beautymail

使用 Laravel 发送漂亮的 HTML 邮件

安装: 42

依赖者: 0

建议者: 0

安全: 0

星标: 4

关注者: 3

分支: 206

语言:CSS

v1.0.6 2015-02-09 20:43 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:10:40 UTC


README

Beautymail 可以让您轻松发送美观的响应式 HTML 邮件。它适用于以下场景:

  • 欢迎邮件
  • 密码提示
  • 发票
  • 数据导出

如果您使用 Laravel 4,请使用 1.x 分支。

模板

市面上有很多优秀的 HTML 邮件模板。Campaign Monitor 和 Mailchimp 已经发布了数百个免费模板。将模板适配到 Beautymail 非常简单。如果您这样做,请发送 PR。

Widgets 来自 Campaign Monitor

Widget Template

Minty 来自 Stamplia

Widget Template

Sunny

Widget Template

安装

通过运行以下命令将包添加到您的 composer.json 文件中

composer require snowfire/beautymail dev-master

安装完成后,将其添加到 config/app.php 文件中的 providers 列表中

Snowfire\Beautymail\BeautymailServiceProvider::class,

将资源发布到您的公共文件夹

php artisan vendor:publish

发送您的第一封 Beauty 邮件

将以下内容添加到您的 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