PHPackages                             a2design-company/mandrill-cakephp-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. a2design-company/mandrill-cakephp-plugin

ActiveCakephp-plugin[API Development](/categories/api)

a2design-company/mandrill-cakephp-plugin
========================================

Mandrill CakePHP plugin

1.0.1(11y ago)193.2k11[1 issues](https://github.com/a2design-inc/Mandrill-CakePHP-plugin/issues)MITPHPPHP &gt;=5.3.0

Since Jan 30Pushed 10y ago17 watchersCompare

[ Source](https://github.com/a2design-inc/Mandrill-CakePHP-plugin)[ Packagist](https://packagist.org/packages/a2design-company/mandrill-cakephp-plugin)[ Docs](https://github.com/a2design-inc/Mandrill-CakePHP-plugin)[ RSS](/packages/a2design-company-mandrill-cakephp-plugin/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Mandrill CakePHP plugin
=======================

[](#mandrill-cakephp-plugin)

### Usage

[](#usage)

This plugin uses [CakeEmail class](http://book.cakephp.org/2.0/en/core-utility-libraries/email.html), and works almost the same.

Basic example:

```
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:

```
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:

```
Global vars example. Here the current date: *|date|*
Email sent for *|name|* (*|email|*)
```

About sub accounts you can read [here](http://help.mandrill.com/forums/22476178-Subaccounts-Basics).

The syntax of all parameters is the same as the default [CakeEmail class](http://book.cakephp.org/2.0/en/core-utility-libraries/email.html).

### Installation

[](#installation)

You can clone the plugin into your project:

```
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

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

```

Bootstrap the plugin in app/Config/bootstrap.php:

```
CakePlugin::load('Mandrill');
```

### Configuration

[](#configuration)

Create the file app/Config/email.php with the class EmailConfig.

```
