Skip to content

economico/clj-mandrill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj-mandrill

A simple Clojure library wrapper for Mandrill the transactional email service from MailChimp.

Build Status

Usage

Add the following to your project.clj's dependencies section:

[clj-mandrill "0.1.0"]

Import the library:

(use 'clj-mandrill.core)

You can call any method listed in the Mandrill V1.0 API

(call-mandrill "users/info" {})

A few of the methods have nicer clojure wrappers around them. I hope to expand this as we go. I will accept pull requests.

Send message

Send an arbitrary message. See Send message API doc for contents of message map:

(send-message {:text "Hi" :subject "Just a note" :from_email "[email protected]" :from_name "Alice"
                :to [{:email "[email protected]" :name "Bob"})

Send message through a template

Mandril supports using templates. This allows you to manage your email content and design outside your app.

Go to My Templates or create them in MailChimp.

See Send message template API doc for contents of message map:

(send-template "verify_email"
                {:subject "Just a note" :from_email "[email protected]" :from_name "Alice"
                  :to [{:email "[email protected]" :name "Bob"})

User information APIS

These are helpful for testing out your connection and validating your emails.

See Users API

=> (ping) ;; Ping server and validate keys
"PONG"

=> (user-info)
{:username "YOURUSERNAME", :created_at "2012-06-29 17:47:55", :public_id "...", :reputation 50, :hourly_quota 25, :backlog 0, :stats {:today {:sent 5, :hard_bounces 0, :complaints 0, :unique_opens 1, :rejects 0, :clicks 1, :soft_bounces 0, :opens 1, :unsubs 0, :unique_clicks 1}, :last_7_days {:sent 5, :hard_bounces 0, :complaints 0, :unique_opens 1, :rejects 0, :clicks 1, :soft_bounces 0, :opens 1, :unsubs 0, :unique_clicks 1}, :last_30_days {:sent 5, :hard_bounces 0, :complaints 0, :unique_opens 1, :rejects 0, :clicks 1, :soft_bounces 0, :opens 1, :unsubs 0, :unique_clicks 1}, :last_60_days {:sent 5, :hard_bounces 0, :complaints 0, :unique_opens 1, :rejects 0, :clicks 1, :soft_bounces 0, :opens 1, :unsubs 0, :unique_clicks 1}, :last_90_days {:sent 5, :hard_bounces 0, :complaints 0, :unique_opens 1, :rejects 0, :clicks 1, :soft_bounces 0, :opens 1, :unsubs 0, :unique_clicks 1}, :all_time {:sent 5, :hard_bounces 0, :complaints 0, :unique_opens 1, :rejects 0, :clicks 1, :soft_bounces 0, :opens 1, :unsubs 0, :unique_clicks 1}}}

=> (senders)
[{:sent 5, :hard_bounces 0, :complaints 0, :unique_opens 1, :rejects 0, :clicks 1, :soft_bounces 0, :created_at "2012-09-28 14:57:41", :opens 1, :unsubs 0, :address "[email protected]", :unique_clicks 1}]

Configuring API Keys

The easiest way to set it up is to set your api key in the MANDRILL_API_KEY environment variable or system property.

Alternatively you can create a dynamic binding for mandrill-api-key.

Use Mailchimp?

We also maintain a simple clojure library Climp for interacting with Mailchimp.

License

Copyright © 2012 PicoMoney Company

Manage and track your startups economy using our new service Economi.co.

Distributed under the Eclipse Public License, the same as Clojure.

About

Clojure library for sending email through Mandrill

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published