clojure-postmark
lets you talk to Postmark from
Clojure.
To get started just slap this in your project.clj
:dependencies
:
[postmark "1.4.0"]
clojure-postmark
works with Clojure 1.8.0.
First you need to load the postmark
function:
; In an (ns)
(:use [postmark.core :only (postmark)])
; Outside an (ns)
(use '[postmark.core :only (postmark)])
Create a customized postmark
function:
(def pm (postmark "YOUR_API_KEY" "from-address@example.com"))
Now just call the function to send an email:
(pm {:to "fluffy@example.com"
:subject "Your Noms"
:text "I wants them."})
You can send to multiple addresses by using a seq for :to
, but remember that
Postmark’s API won’t let you send to more than twenty recipients at a time:
(pm {:to ["fluffy@example.com" "sprinkles@example.com"]
:subject "All of Your Noms"
:text "I wants them."})
There are a few other keys you can use in the map you pass to the call:
(pm {:to ["fluffy@example.com" "sprinkles@example.com"]
:cc ["haiku@example.com"]
:bcc ["admin@example.com"]
:subject "All of Your Noms"
:text "I wants them."
:html "I <b>wants</b> them."
:tag "Noms"
:reply-to "avedon@example.com"})
If you just want to run a test you can use postmark-test
without an API key
instead of postmark
:
(use '[postmark.core :only (postmark-test)])
(def pt (postmark-test "from-address@example.com"))
(pt {:to ["fluffy@example.com" "sprinkles@example.com"]
:subject "Testing"
:text "I might want your noms."})
Created by Steve Losh, and maintained by Daniel Compton.