dev-master
9999999-dev https://github.com/metaline/mailmatics-sdk-phpThe Mailmatics PHP SDK
MIT
The Requires
- php >=5.4
- psr/log ^1.0
The Development Requires
by Daniele De Nobili
newsletter sdk mailmatics
Wallogit.com
2017 © Pedro PelĂĄez
The Mailmatics PHP SDK
A PHP client for the Mailmatics API., (*1)
This library is in development. Use it at your risk., (*2)
The recommended way to install PHP Mailmatics SDK is through Composer., (*3)
$ curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version:, (*4)
$ php composer.phar require mailmatics/php-sdk
After installing, you need to require the Composerâs autoloader:, (*5)
require 'vendor/autoload.php';
PHP Mailmatics SDK supports two authentication modes:, (*6)
1. API key:, (*7)
use Mailmatics\Client; $client = new Client(['apiKey' => '...']);
2. Simple login:, (*8)
use Mailmatics\Client; $client = new Client(['username' => 'admin', 'password' => '12345']);
TODO, (*9)
Internally, PHP Mailmatics SDK uses an implementation of Mailmatics\HttpClientInterface. The default is Mailmatics\HttpClient\StreamClient. You can change it by passing it to the client constructor:, (*10)
use Mailmatics\Client; use Mailmatics\HttpClient\CurlClient; $client = new Client($credentials, $options, new CurlClient());
The more powerful implementation is the Mailmatics\HttpClient\GuzzleHttpClient, that require the Guzzle library., (*11)
use Mailmatics\HttpClient\GuzzleHttpClient; $httpClient = new GuzzleHttpClient();
You can pass your instance of Guzzle client in the constructor:, (*12)
use GuzzleHttp\Client as GuzzleClient; use Mailmatics\HttpClient\GuzzleHttpClient; $guzzleClient = new GuzzleClient(); $httpClient = new GuzzleHttpClient($guzzleClient);
Get all lists:, (*13)
$lists = $client->getLists()->all();
Get a single list:, (*14)
$list = $client->getLists()->get(123);
$list = $client->getLists()->addSubscriber($listId, $email);
You can specify also first and last name:, (*15)
$data = [
'firstname' => 'John',
'lastname' => 'Smith',
];
$list = $client->getLists()->addSubscriber(123, $email, $data);
...or the fullname (Mailmatics automagicaly split first and last name):, (*16)
$data = [
'fullname' => 'John Smith',
];
$list = $client->getLists()->addSubscriber(123, $email, $data);
To unsubscribe a user from a list, you must have his subscriber ID., (*17)
$list = $client->getLists()->unsubscribe($listId, $subscriberId);
TODO: How can I obtain the subscriber ID?, (*18)
Get all transactional emails:, (*19)
$emails = $client->getTransactional()->all();
Get a single transactional email:, (*20)
$email = $client->getTransactional()->get(123);
Send a transactional email:, (*21)
$data = [
'firstName' => 'John',
'lastName' => 'Smith'
];
$email = $client->getTransactional()->send(123, 'john@example.com', $data);
Send a scheduled transactional email:, (*22)
$data = [
'firstName' => 'John',
'lastName' => 'Smith'
];
$schedule = new DateTime('2018-12-25 12:30:00');
$email = $client->getTransactional()->send(123, 'john@example.com', $data, $schedule);
This library is licensed under the MIT License - see the LICENSE file for details., (*23)
The Mailmatics PHP SDK
MIT
newsletter sdk mailmatics