A CakePHP component to allow sending emails through PostageApp
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
controllers/components
LICENSE
README.md

README.md

PostageApp for CakePHP

This is a component for CakePHP to replace the EmailComponent and allows you to send emails with PostageApp service. Personalized, mass email sending can be offloaded to PostageApp via the JSON based API.

API DocumentationPostageApp FAQsPostageApp Help Portal

Installation

Manual

GIT Submodule

In your app directory type:

git submodule add git://github.com/postageapp/postageapp-cakephp.git plugins/postage
git submodule init
git submodule update

GIT Clone

In your plugin directory type

git clone git://github.com/postageapp/postageapp-cakephp.git postage

Usage

PostageApp for CakePHP works very similarly to built-in EmailComponent. Here's a simple example (in a controller):

var $components = array('Postage.Postage' => array(
    'api_key' => 'PLEASE CHANGE ME TO YOUR PROJECT API KEY',
));

function send() {
    $this->Postage->from = 'sender@test.test';
    $this->Postage->to = 'recipient@test.test';
    $this->Postage->subject = 'Example Email';
    $this->Postage->htmlMessage = '<strong>Example Message</strong>';
    $this->Postage->textMessage = 'Example Message';
    $this->Postage->attachments = array('/path/to/a/file.ext', '/path/to/a/file2.ext');

    $this->Postage->template = 'test-template';
    $this->Postage->variables = array('variable' => 'value');

    $this->Postage->send(); # returns JSON response from the server
}

Recipients can be specified in a number of ways. Here's how you define a list of them with variables attached:

$this->Postage->to = array(
  'recipient1@example.com' => array('variable1' => 'value',
                                    'variable2' => 'value'),
  'recipient2@example.com' => array('variable1' => 'value',
                                    'variable2' => 'value')
);

For more information about formatting of recipients, templates and variables please see documentation