PHP Bindings for
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Apostle PHP

Build Status Latest Stable Version

PHP bindings for


With Composer

Add apostle/apostle-php to composer.json.

    "require": {
        "apostle/apostle-php": "v0.1.5"

Without Composer

Download the latest release. Ensure src is in your autoload path. If you’re not using auto loading, require the following files:

  • Apostle.php
  • Apostle\Queue.php
  • Apostle\Mail.php
  • Aposlte\UninitializedException.php


Domain Key

You will need to provide your apostle domain key to send emails.


Sending Email

Sending a single email is easy, the first param is your template's slug, and the second is an array of data.

use Apostle\Mail;

$mail = new Mail(
	array("email" => "", "name" => "Mal Curtis")


You don‘t have to add the data at initialization time, feel free to add it after. You can add in any data your template needs too.

$mail = new Mail("template-slug");
$mail->email = "";
$mail->name = "Mal Curtis";
$mail->from = "";
$mail->replyTo = "";
$mail->website = ""; // You can add any data your template needs


Attachments can be added by supplying a filename and content as a string.

$mail = new Mail("template-slug");
$mail->addAttachment("test.txt", "Some test text");


Pass a variable for failure information to the deliver method.

$mail = new Apostle\Mail("template-slug");

echo $mail->deliver($failure);
// false

echo $failure;
// No email provided

Sending Multiple Emails

To speed up processing, you can send more than one email at a time.

use Apostle\Mail;
use Apostle\Queue;

$queue = new Queue();

	$mail = new Mail("template-slug");
	$mail->email = "user" . $i . "";



If any Mail object fails validation then no emails will be sent. To retrieve failed objects, you can supply a variable to be populated.

use Apostle\Mail;
use Apostle\Queue;

$queue = new Queue();

$mail = new Mail("template-slug");

$mail = new Mail(null, ["email" => ""]);

echo $queue->deliver($failures);
// false

echo count($failures);
// 2

echo $failures[0]->deliveryError();
// "No email provided"

echo $failures[1]->deliveryError();
// "No template provided"


  • PHP 5.3+


Created with ♥ by Mal Curtis (@snikchnz)


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request