2017 © Pedro Peláez
 

library ornamental

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

image

mikejestes/ornamental

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

  • Monday, December 1, 2014
  • by mikejestes
  • Repository
  • 3 Watchers
  • 8 Stars
  • 1,374 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 17 Versions
  • 0 % Grown

The README.md

Ornamental

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

Build Status, (*2)

Installation

Add to your composer.json file:, (*3)

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

Then download and run composer:, (*4)

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., (*5)

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}}})., (*6)

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:, (*7)

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

Current Plugins

Templating: * mustache (install mustache/mustache from composer) * php, (*8)

Mail Transport: * phpmailer (install phpmailer/phpmailer) * log file, (*9)

Integration with unit tests

Unit tests can inspect the send log:, (*10)

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

The Versions

01/12 2014

dev-master

9999999-dev https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

01/12 2014

0.2.3

0.2.3.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

01/07 2014

0.2.2

0.2.2.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

03/05 2014

0.2.1

0.2.1.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

17/04 2014

0.2.0

0.2.0.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

07/03 2014

0.1.2

0.1.2.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

06/03 2014

0.1.1

0.1.1.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

27/01 2014

0.1.0

0.1.0.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

20/12 2013

0.0.9

0.0.9.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

13/11 2013

0.0.8

0.0.8.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

13/11 2013

0.0.7

0.0.7.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

09/10 2013

0.0.6

0.0.6.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

04/10 2013

0.0.5

0.0.5.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

12/09 2013

0.0.4

0.0.4.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

10/09 2013

0.0.3

0.0.3.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

10/09 2013

0.0.2

0.0.2.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template

08/02 2013

0.0.1

0.0.1.0 https://github.com/mikejestes/ornamental

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

  Sources   Download

MIT

The Requires

 

The Development Requires

email template