2017 © Pedro Peláez
 

cakephp-plugin mandrill-cakephp-plugin

Mandrill CakePHP plugin

image

a2design-company/mandrill-cakephp-plugin

Mandrill CakePHP plugin

  • Wednesday, December 16, 2015
  • by MrMYSTIC
  • Repository
  • 18 Watchers
  • 19 Stars
  • 2,651 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 1 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

Mandrill CakePHP plugin

Usage

This plugin uses CakeEmail class, and works almost the same., (*1)

Basic example:, (*2)

App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail('mandrill');

$email->to('recipient@domain.com');
$email->subject('Test email via Mandrill');
$email->send('Message');

More advanced example:, (*3)

App::uses('CakeEmail', 'Network/Email');

$email = new CakeEmail(array(
    'transport' => 'Mandrill.Mandrill',
    'from' => 'from@example.com',
    'fromName' => 'FromName',
    'timeout' => 30,
    'api_key' => 'YOUR_API_KEY',
    'emailFormat' => 'both',
));

$viewVars = array(
    'var1' => 'some1',
    'var2' => 'some2'
);

$to = array(
    'to1@example.com',
    'to2@example.com',
);

$email->addHeaders(array(
    'tags' => array('test',),
    'subAccount' => 'YOUR_SUBACCOUNT',
    'preserve_recipients' => false,
    'global_merge_vars' => array(
        array(
            'name' => 'date',
            'content' => date('Y-m-d'),
        ),
    ),
    'merge_vars' => array(
        array(
            'rcpt' => 'to1@example.com',
            'vars' => array(
                array(
                    'name' => 'email',
                    'content' => 'to1@example.com'
                ),
                array(
                    'name' => 'name',
                    'content' => 'to1Name'
                ),
            )
        ),
        array(
            'rcpt' => 'to2@example.com',
            'vars' => array(
                array(
                    'name' => 'email',
                    'content' => 'to2@example.com'
                ),
                array(
                    'name' => 'name',
                    'content' => 'to2Name'
                ),
            )
        ),
    ),
));

$email->addAttachments(array(
    'example.pdf' => array(
        'file' => APP . '/webroot/files/readme.pdf',
        'mimetype' => 'application/pdf',
    ),
    'logo.png' => array(
        'file' => APP . '/webroot/img/logo.png',
        'mimetype' => 'image/png',
//      'contentId' => 'headerLogo', // Uncomment this line if you want use inline image
));

$email->template('test', 'default');
$email->viewVars($viewVars);
$email->to($to);
$email->subject('Mandrill CakePHP Plugin Test');

$email->send();

Part of email template:, (*4)

<p>Global vars example. Here the current date: *|date|*</p>
<p>Email sent for *|name|* (*|email|*)</p>

About sub accounts you can read here., (*5)

The syntax of all parameters is the same as the default CakeEmail class., (*6)

Installation

You can clone the plugin into your project:, (*7)

cd path/to/app/Plugin
git clone git@github.com:a2design-company/Mandrill-CakePHP-plugin.git Mandrill

Also you can use composer for install this plugin. Just add new requirement to your composer.json, (*8)

"require": {
    ...,
    "a2design-company/mandrill-cakephp-plugin": "*"
},

Bootstrap the plugin in app/Config/bootstrap.php:, (*9)

CakePlugin::load('Mandrill');

Configuration

Create the file app/Config/email.php with the class EmailConfig., (*10)

<?php
class EmailConfig {
    public $mandrill = array(
        'transport' => 'Mandrill.Mandrill',
        'from' => 'from@example.com',
        'fromName' => 'FromName',
        'timeout' => 30,
        'api_key' => 'YOUR_API_KEY',
        'emailFormat' => 'both',
    );
}

Requirements

CakePHP 2.0+, (*11)

License

Licensed under The MIT License, (*12)

Developed by A2 Design Inc., (*13)

The Versions

16/12 2015

dev-master

9999999-dev https://github.com/a2design-inc/Mandrill-CakePHP-plugin

Mandrill CakePHP plugin

  Sources   Download

MIT

The Requires

 

api cakephp mandrill

12/05 2015

1.0.1

1.0.1.0 https://github.com/a2design-inc/Mandrill-CakePHP-plugin

Mandrill CakePHP plugin

  Sources   Download

MIT

The Requires

 

api cakephp mandrill

30/01 2015

1.0.0

1.0.0.0 https://github.com/a2design-company/Mandrill-CakePHP-plugin

Mandrill CakePHP plugin

  Sources   Download

MIT

The Requires

 

api cakephp mandrill