2017 © Pedro Peláez
 

library apostle-php

Apostle PHP Client

image

apostle/apostle-php

Apostle PHP Client

  • Tuesday, January 20, 2015
  • by snikch
  • Repository
  • 5 Watchers
  • 16 Stars
  • 10,181 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 3 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Apostle PHP

Build Status Latest Stable Version, (*1)

PHP bindings for Apostle.io, (*2)

Installation

With Composer

Add apostle/apostle-php to composer.json., (*3)

{
    "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:, (*4)

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

Prerequisites

Domain Key

You will need to provide your apostle domain key to send emails., (*5)

Apostle::setup("your-domain-key");

Sending Email

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

use Apostle\Mail;

$mail = new Mail(
    "template-slug",
    array("email" => "mal@apostle.io", "name" => "Mal Curtis")
);

$mail->deliver();

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., (*7)

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

$mail->deliver();

Attachments can be added by supplying a filename and content as a string., (*8)

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

Failure

Pass a variable for failure information to the deliver method., (*9)

$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., (*10)


use Apostle\Mail; use Apostle\Queue; $queue = new Queue(); for($i=0;$i<5;$i++){ $mail = new Mail("template-slug"); $mail->email = "user" . $i . "@example.org"; $queue->add($mail); } $queue->deliver();

Failures

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


use Apostle\Mail; use Apostle\Queue; $queue = new Queue(); $mail = new Mail("template-slug"); $queue->add($mail); $mail = new Mail(null, ["email" => "user@example.org"]); $queue->add($mail); echo $queue->deliver($failures); // false echo count($failures); // 2 echo $failures[0]->deliveryError(); // "No email provided" echo $failures[1]->deliveryError(); // "No template provided"

Requirements

  • PHP 5.3+

Who

Created with ♥ by Mal Curtis (@snikchnz), (*12)

Contributing

  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

The Versions

20/01 2015

dev-master

9999999-dev

Apostle PHP Client

  Sources   Download

The Requires

 

The Development Requires

by Mal Curtis

apostle

20/01 2015

v0.1.5

0.1.5.0

Apostle PHP Client

  Sources   Download

The Requires

 

The Development Requires

by Mal Curtis

apostle

17/12 2013

v0.1.4

0.1.4.0

Apostle PHP Client

  Sources   Download

The Requires

 

The Development Requires

by Mal Curtis

apostle

21/11 2013

v0.1.2

0.1.2.0

Apostle PHP Client

  Sources   Download

The Requires

 

The Development Requires

by Mal Curtis

apostle

21/11 2013

v0.1.1

0.1.1.0

Apostle PHP Client

  Sources   Download

The Requires

 

The Development Requires

by Mal Curtis

apostle

21/10 2013

v0.1.0

0.1.0.0

Apostle PHP Client

  Sources   Download

The Requires

 

The Development Requires

by Mal Curtis

apostle