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.
Manual
- Download this: http://github.com/postageapp/postageapp-cakephp/zipball/master
- Unzip that download.
- Copy the resulting folder to app/plugins
- Rename the folder you just copied to
postage
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 postagePostageApp 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