定制 mikejestes/ornamental 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mikejestes/ornamental

Composer 安装命令:

composer require mikejestes/ornamental

包简介

A library to send templated transactional emails, and easily test.

README 文档

README

A library to send templated transactional emails. Plugins for your choice of template language and mail sending library. Configuration through YAML.

Build Status

Installation

Add to your composer.json file:

"require": {
    "mikejestes/ornamental": "*"
}

Then download and run composer:

curl -s https://getcomposer.org/installer | php
php composer.phar install

Defining Messages

Yaml files configure each email message type. The filename minus .yaml is the key when constructing a \Ornamental\Message object.

from: service@example.com
fromName: "{{ company }}"
to: "{{user.email}}"
subject: "Welcome to Ornamental, {{user.name}}"
layout: welcome
template: user_welcome
required:
    - user

Layouts

Layout files can be used to separate themes. The body of each individual message is injected with the body variable, which should be unescaped in mustache ({{{body}}}).

Configuration

$setup = \Ornamental\Settings::getInstance();
$setup->templateDir = __DIR__ . '/templates/';
$setup->layoutDir = __DIR__ . '/layouts/';
$setup->messageDir = __DIR__ . '/messages/';

// optionally prefix emails with a string
$setup->subjectPrefix = '[test] ';

// set default variables across all messages
$setup->defaults = array(
    'website_url' => 'http://example.com/',
);

// add phpmailer sender
$phpmailer = new \Ornamental\Sender\Phpmailer();
$phpmailer->smtpHost = 'smtp.example.com';
$phpmailer->smtpUsername = 'root';
$phpmailer->smtpPassword = 'password';

$setup->addSender($phpmailer);

//  \Ornamental\Sender\Logger is a sender that logs to a PSR logger class
$setup->addSender(new \Ornamental\Sender\Logger($logger));

Usage

Data as passed to each template by setting properties on the \Ornamental\Message object:

$email = new \Ornamental\Message('user_welcome');
$email->user = array('name' => "Joe User");
$email->send();

Current Plugins

Templating:

  • mustache (install mustache/mustache from composer)
  • php

Mail Transport:

  • phpmailer (install phpmailer/phpmailer)
  • log file

Integration with unit tests

Unit tests can inspect the send log:

$deliveries = \Ornamental\Deliveries::getInstance();
$this->assertEquals(2, count($deliveries->log));

统计信息

  • 总下载量: 1.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-09-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固