Skip to content


Subversion checkout URL

You can clone with
Download ZIP


joebeeson edited this page · 9 revisions

Mailer is a CakePHP 1.3 plugin for simplifying the sending of emails.


  • The sending of an email is handled by interchangeable transport objects (Classes - \Postman\Library\Transport).
  • Emails are independent, reusable objects.
  • Send emails from anywhere: controller, shell, etc.
  • Easy to extend and build upon.


To begin we have to create an Email object (Classes - \Postman\Library\Email). This object will hold all the various information, recipients, content and attachments that are pertinent to the email being sent.

    $email = $this->Postman->create('', 'Email subject');

Now we can begin attaching various pieces of information to the email object.

    // Lets add some recipients...
    $email->addRecipient('', 'cc');
    $email->addRecipient('', 'bcc');

    // Now maybe some files
    $email->addAttachment('/tmp/report.xls', 'BigReport.xls');
    $email->addAttachment('/tmp/summary.doc', 'Summary.doc');

    // Finally, our email's body
    $email->setTextBody('Hey there guys, check out this report!');
    $email->setHtmlBody('<strong>HI!</strong>. Reports inside.');

At this point our Email object should be all set and we should hand the object off for sending. We will receive a boolean response to indicate success.

    if ($this->Postman->send($email)) {
        echo 'Success!';
    } else {
        echo 'Ruh-roh.';
Something went wrong with that request. Please try again.