Mandrill

Mandrill

Master Branch Build Status

This is a ColdBox Module to use with the Mandrill API. See the Mandrill API Documentation for more information about the service.

Requirements

  • Lucee 5.2+
  • ColdBox 4.3+
  • Java 8+

Installation

Install using CommandBox: box install mandrill

Within config/Coldbox.cfc add a module settings element named mandrill and define your Mandrill API key in apiKey. Optionally, the default endpoint base URL (https://mandrillapp.com/api/1.0/) may be overridden using endpointBaseUrl:

moduleSettings = {
    "mandrill" = {
        "apiKey" = "YOUR_API_KEY"
    }
};

Usage

The Mandrill client will be instantiated and configured on ColdBox application startup. Inject it where needed, or request it by name. Here's how one might send a message from a ColdBox Handler:

var message = {
    "html": "<h1>Way To Go Donny!</h1><p>If you will it, Dude, it is no dream.</p>",
    "subject": "Over The Line",
    "from_email": "[email protected]",
    "from_name": "Walter Sobchak",
    "to": [
        {
            "email": "[email protected]",
            "name": "Theodore Donald 'Donny' Kerabatsos"
        },
        {
            "email": "[email protected]",
            "name": "The Dude"
        }
    ]
};
getInstance("[email protected]").messages.send(message=message);

It's important to note that the sender address for messages sent through Mandrill must match a verified domain. See the knowledge base article on this topic for more information.

Support

This project is an attempt to mimic the official Mandrill libraries for Python and Node.js. All of the features of the Mandrill API aren't implemented yet. Here's a summary of the calls supported in this version:

/users/info Mandrill.users.info()

/messages/send Mandrill.messages.send(required struct message, boolean async, string ip_pool, string send_at)

/messages/send-template Mandrill.messages.send_template(required string template_name, required array template_content, required struct message, boolean async, string ip_pool, string send_at)

/rejects/list Mandrill.rejects.list(string email, boolean include_expired, string subaccount)

/rejects/add Mandrill.rejects.add(required string email, string comment, string subaccount)

/rejects/delete Mandrill.rejects.delete(required string email, string subaccount)

/whitelists/list Mandrill.whitelists.list(string email)

/whitelists/add Mandrill.whitelists.add(required string email, string comment)

/whitelists/delete Mandrill.whitelists.delete(required string email)

Tests

The package is configured such that tests can be executed within CommandCox using testbox run after the embedded server is started with server start.

By default, the REST calls to Mandrill are mocked. To run the tests against the live Mandrill service, define an API key and authorized domain. If you have the dotEnv CommandBox system module installed, this is pretty easy. See the .env.example file in the project root. It defines the two configuration options:

mandrill.api.key=secret
mandrill.auth.domain=authorized.tld

Copy the example as .env and plug in your values.

Another option is to configure environment variables in the shell before starting CommandBox. For example:

export MANDRILL_API_KEY="secret"
export MANDRILL_AUTH_DOMAIN="authorized.tld"

License

See the LICENSE file for license rights and limitations (MIT).

Here are all the versions for this package. Please note that you can leverage CommandBox package versioning to install any package you like. Please refer to our managing package version guide for more information.

Version Created Last Update Published By Stable Download
0.0.4 Dec 21 2018 03:07 PM Dec 21 2018 03:07 PM Joseph Lamoree (jlamoree)
0.0.3 Oct 11 2018 06:15 PM Oct 11 2018 06:15 PM Joseph Lamoree (jlamoree)
0.0.2 Oct 31 2017 07:42 PM Oct 31 2017 07:42 PM Joseph Lamoree (jlamoree)
0.0.1 Sep 28 2017 01:06 AM Sep 28 2017 01:06 AM Joseph Lamoree (jlamoree)

 

No collaborators yet.
     
  • Sep 28 2017 01:06 AM
  • Dec 21 2018 03:07 PM
  • 394
  • 0
  • 232