sendgrid-clj
sendgrid-clj copied to clipboard
A Clojure library for SendGrid
Sendgrid
A Clojure library for SendGrid
Installation
Add the following to your dependencies to install sendgrid from Clojars.
[io.forward/sendgrid-clj "1.0"]
Use
All functions require authorization which is just a map with the following keys
(in-ns 'your-ns
(:require [sendgrid-clj.core]))
(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 "[email protected]", :active "true", :first_name "Owain",
;; :zip "", :address "",
;; :website "http://owainlewis.com"}
To send an email message via SendGrid. Note that certain keys are required
(send-email auth {
:to "[email protected]"
:from "[email protected]"
:subject "Mail"
:html "<h1>Hello world</h1?"
:text "Hello world"})
;; {:message "success"}
Sending an attachment
If you'd like to send an attachment with your email, pass an attachment map as a param:
(send-email auth {
:to "[email protected]"
:from "[email protected]"
:subject "Mail"
:text "<h1>Hello world</h1>"
:attachment {:title "huzzah!"
:content-type "text/csv"
:file (io/file "huzzah.csv")}})
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 [email protected]
> export SENDGRID_PASSWORD=xxyyzz2244
> export [email protected]
> lein test
<... testing output ...>
License
Distributed under the Eclipse Public License, the same as Clojure.