helthe/mandrill

Helthe Mandrill Component

dev-master / 1.0.x-dev 2014-05-14 16:19 UTC

This package is auto-updated.

Last update: 2024-11-29 05:03:12 UTC


README

Helthe Mandrill is a client library for interacting with the Mandrill API. It is currently designed to be a drop in alternative for sending emails with Mandrill. Features will be added over time to be closer to the official client library. However, for a feature complete client, you should use the official Mandrill client library.

Installation

Using Composer

Manually

Add the following in your composer.json:

{
    "require": {
        // ...
        "helthe/mandrill": "dev-master"
    }
}

Using the command line

$ composer require 'helthe/mandrill=dev-master'

Usage

Client

The Mandrill client uses a Guzzle client for interacting with the Mandrill API and the Symfony Serializer for serializing the data. The serializer is expected to have CustomNormalizer and the JsonEncoder.

use GuzzleHttp\Client as GuzzleClient;
use Helthe\Component\Mandrill\Client;
use Helthe\Component\Mandrill\Message\Message;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
use Symfony\Component\Serializer\Serializer.

// GuzzleHttp\ClientInterface
$guzzle = new GuzzleClient();
// Symfony\Component\Serializer\SerializerInterface
$serializer = new Serializer(array(new CustomNormalizer()), array(new JsonEncoder()));

$client = new Client($guzzle, $serializer, 'your_api_key');

$client->sendMessage(new Message('recipient@email.com', 'sender@email.com');

Mailer

The mailer classes are design to hide internal workings of the library and offer a standard interface for sending messages. The package offers two mailer classes for you to use.

Mailer

The Mailer class is used when you want to send regular text/HTML messages.

TemplatingEngineMailer

The TemplatingEngineMailer class is used when you want to render your message content with using a templating engine implementing the EngineInterfacefrom the Symfony Templating Component.

Bugs

For bugs or feature requests, please create an issue.