/sendgrid

Use the SendGrid API in Clojure applications

Primary LanguageClojure

Sendgrid

A Clojure library for SendGrid

Installation

Add the following to your dependencies to install sendgrid from Clojars.

[sendgrid "0.1.0"]

Use

All functions require authorization which is just a map with the following keys

(def auth {:api_user "blah" :api_key "blah"})
(profile auth)

;; {:country "GB", :last_name "Lewis", :state "", :website_access "true",
;;  :address2 "", :city "Cardiff", :username "owainlewis", :phone "",
;;  :email "owain@owainlewis.com", :active "true", :first_name "Owain",
;;  :zip "", :address "",
;;  :website "http://owainlewis.com"}

Mail

To send an email message via SendGrid. Note that certain keys are required

(send-email auth {
  :to "owain@owainlewis.com"
  :from "jack@twitter.com"
  :subject "Mail"
  :text "<h1>Hello world</h1>"})

;; {:message "success"}

Stats

(stats auth)

;; With extra params

(stats auth {:start_date "" :end_date ""})

Testing

Export SENDGRID_PASSWORD and SENDGRID_USERNAME in your shell, then run the tests.

> export SENDGRID_USERNAME=app123XYZ@heroku.com
> export SENDGRID_PASSWORD=xxyyzz2244
> export SENDGRID_TO_ADDR=you@wherever.com
> lein test
<... testing output ...>

License

Copyright © 2013 FIXME

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