A Clojure library for consuming the Mandrill API.
(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 "nobody@example.com"
:name "Nobody"}]
:from_email "you@yourdomain.com"
: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)
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
.
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
Copyright © 2014 Gordon Stratton
Licensed under the Apache License version 2.0.