PHPackages                             jmillerdesign/mandrill - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. jmillerdesign/mandrill

ActiveCakephp-plugin[Mail &amp; Notifications](/categories/mail)

jmillerdesign/mandrill
======================

This enables using CakeEmail from CakePHP 2.x with Mandrill

2.2.2(11y ago)11.3k4MITPHPPHP &gt;=5.3.0

Since Nov 22Pushed 10y ago3 watchersCompare

[ Source](https://github.com/jmillerdesign/MandrillTransport-CakePHP)[ Packagist](https://packagist.org/packages/jmillerdesign/mandrill)[ Docs](https://github.com/jmillerdesign/MandrillTransport-CakePHP/)[ RSS](/packages/jmillerdesign-mandrill/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Mandrill CakePHP Plugin
=======================

[](#mandrill-cakephp-plugin)

This enables using CakeEmail from CakePHP 2.0 with Mandrill.

Installation
------------

[](#installation)

1. Copy this directory to `/app/Plugin/Mandrill` (or if you want you can use as a [submodule](http://help.github.com/submodules)):

    ```
     git clone https://github.com/jmillerdesign/MandrillTransport-CakePHP.git app/Plugin/Mandrill;

    ```
2. Add an email configuration for the Mandrill Transport protocol. Add this to `/app/Config/email.php`. You may find it named `email.php.default`.

    ```
     public $mandrill = array(
     	'transport' => 'Mandrill.Mandrill',
     	'uri' => 'https://mandrillapp.com/api/1.0/',
     	'key' => 'your-key-here'
     );

    ```

    Be sure to update the API Key to your own key.
3. Load the plugin in `/app/Config/bootstrap.php`.

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

    ```

Config
------

[](#config)

Mandrill has many options that can be passed with messages, which are described in the [Mandrill API Documentation](https://mandrillapp.com/api/docs/messages.html). You can pass these to this plugin in the email configuration (ex. 1) or with $email-&gt;config() (ex. 2).

##### Example 1 (global config)

[](#example-1-global-config)

```
	public $mandrill = array(
		'transport' => 'Mandrill.Mandrill',
		'uri' => 'https://mandrillapp.com/api/1.0/',
		'key' => 'your-key-here',
		'track_opens' => true,
		'track_clicks' => true
	);

```

##### Example 2 (instance config)

[](#example-2-instance-config)

```
	$email->config(array(
		'tags' => array('password_reset'),
		'template_name' => 'password_reset',
		'auto_html' => false
	));

```

Outbound Email Usage
--------------------

[](#outbound-email-usage)

Usage is based on the `CakeEmail` class and specification.

To use, import the `CakeEmail` class:

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

```

and use it like so when you want to send an email.

```
$email = new CakeEmail();
$email->config('mandrill');
$email->from('noreply@yourapp.com');
$email->to('email@domain.com');
$email->subject('Subject for Email');
$result = $email->send();

```

The `$result` object will contain information about the success or failure of the message sending. `$result` will contain the `Mandrill` key, which contains the response from Mandrill.

### Use template settings for *from* and *subject*

[](#use-template-settings-for-from-and-subject)

In the above example, if you don't set `$email->subject()`, then it will use Mandrill's template setting instead. If you set the `from` email address and/or name to `mandrill@example.com`, then it will use Mandrill's template setting instead. *Note: Setting a from address is required by Cake.*

Inbound Email Usage
-------------------

[](#inbound-email-usage)

1. Configure [mandrillapp.com/inbound](https://mandrillapp.com/inbound) and point the Webhook to `http://example.com/mandrill/emails/inbound` (replace example.com with your live domain URL)
2. Create an event handler if you want to do something whenever you receive an email. In your controller:

    ```
