Awesome Open Source
Awesome Open Source

clj-mandrill

Status of clj-mandrill build (master branch). Status of clj-mandrill dependencies.

A Clojure library for consuming the Mandrill API.

Installation

Clojars Project

Documentation

API documentation

Usage

(ns your.app
  (:require [gws.mandrill.client :as client]
            [gws.mandrill.api.messages :as messages]))

; Create a default Mandrill client with your API key. You can also specify a map
; of clj-http parameters, but that's optional.
(def client (client/create "YOUR-SECRET-KEY"))
;(def client (client/create "YOUR-SECRET-KEY" {:socket-timeout 1000}))

; Build up an interesting message to send.
(def msg {:message {:to [{:email "[email protected]"
                          :name "Nobody"}]
                    :from_email "[email protected]"
                    :subject "This is a test"
                    :text "Really interesting text-only content."}})
; You can override the key per-request, per the Mandrill docs. This will
; override your client API key configuration.
;(def msg {:key "YOUR KEY"
;          :message {...}})

; Send the message using the configured Mandrill client.
; Functions are named in an attempt to be consistent with the Mandrill REST API
; endpoints.
(messages/send client msg)

Features

The entire Mandrill API version 1.0 is supported.

The API follows the Mandrill API conventions as closely as possible. In other words, messages calls are in the gws.mandrill.api.messages namespace, and the calls are lowercased functions in that namespace, such as gws.mandrill.api.messages/send.

Testing

Most of the tests are run against the actual Mandrill API, since Mandrill provides test API keys. In order to actually run the tests, you need to obtain a test API key. Once you’ve done this, you can supply the key as an environment variable:

# Be absolutely sure this is a test key, not your production key!
MANDRILL_TEST_API_KEY=YOURTESTKEY lein test

License

Copyright © 2014 Gordon Stratton

Licensed under the Apache License version 2.0.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
clojure (1,937
email (295

Find Open Source By Browsing 7,000 Topics Across 59 Categories