orainteractive/cakephp3-email-template

Email Template for CakePHP3 based on HTML Email Layouts by MailChimp

v1.1.0 2015-07-13 01:24 UTC

This package is not auto-updated.

Last update: 2024-04-13 15:55:51 UTC


README

Build Status Latest Stable Version License Total Downloads

About

Email Template for CakePHP 3 is based on HTML Email Layouts by MailChimp and Gourmet/Email.

Specifically, using a modified version of the Base Boxed Basic Query resposive template.

##Installation

The recommended installation way is through Composer.

$ composer require orainteractive/cakephp3-email-template

Load the plugin in config/bootstrap.php:

Plugin::load('Ora/Email');

Update your email configuration in config/app.php, example shows default configuration:

'Email' => [
	'default' => [
		'transport' => 'default',
		'from' => 'you@localhost',
        'charset' => 'utf-8',
        'headerCharset' => 'utf-8',
        'layout' => 'Ora/Email.default',
        'emailFormat' => 'both',
        'helpers' => [
            'Ora/Email.Email' => [
                'modifiers' => [
                    'inline' => true,
                    'clean' => true,
                ],
                'regEx' => [
                    '' => [
                        '/<!--(.|\s)*?-->/' => '',
                        '!/\*[^*]*\*+([^/][^*]*\*+)*/!' => '',
                    ],
                ],
                'template' => [
                    'company' => 'My Company LLC',
                    'fontColor' => '#000000',
                    'backgroundColor' => '#FFFFFF',
                    'foregroundColor' => '#CECECE',
                    'logo' => 'https://s3.amazonaws.com/assets.myapp.com/email/logo.png',
                    'homeLink' => 'http://myapp.com',
                    'facebookLink' => 'http://facebook.com/myapp',
                    'twitterLink' => 'http://twitter.com/myapp',
                ],
            ],
        ],
	],
],

Documentation

The following modifier properties can be used to modify the HTML prior to sending:

Property Default Description
clean false Performs a clean on HTML based on RegEx
regEx ``[ '/<!--(. \s)?-->/' => '' , '!/*[^*]*+([^/][^*]*+)/!' => '' ]``
inline false Inlines CSS

Inline CSS uses tijsverkoyen/CssToInlineStyles

The following template properties can be used in the template configuration:

Property Default Description
backgroundColor #FFFFFF Background color for email
company Name of the company (ex. Ora Interactive LLC)
facebookLink Facebook URL for app
fontColor #000000 Fond color for the email
foregroundColor #FFFFFF Foreground color for email
homeLink URL of app homepage
logo Full path URL for logo
twitterLink Twitter URL for app

Usage

In your app, send Emails as normal:

use Cake\Network\Email\Email;

$email = new Email('default');
$email->to($user->email)
    ->subject('Welcome to my app!')
    ->template('welcome')
    ->send('Hope you enjoy using my app.');

License

Copyright (c) 2015, Ora Interactive and licensed under The MIT License.