https://github.com/flyingmachine/penny-black

Penny Black allows you to declaratively create functions which send HTML 
and text emails using mustache templates. It's inspired by ActionMailer. 
You might find it useful if you have an application that sends email :)

Here's an example of defining and then calling an email function (taken 
from the github readme):

;; it's necessary to require both the correct backend and
;; com.flyingmachine.penny-black.core.send in order to define your senders
;; Why? Becase v0.1.0
(ns whatever
  (:require com.flyingmachine.penny-black-apache-commons
            [com.flyingmachine.penny-black.core.send :refer (defsenders)]))

;; Create the sending functions. Example of calling them below.
(defsenders
  ;; A list of args that each sending function will take
  {:args [users topic]
   :user-doseq [user users]}
  ;; senders iterate over a seq and send an email for each element
  ;; :user-doseq specifies which argument from :args corresponds to
  ;; the seq ("users") and what name to use for each element ("user").
  ;; This way you have access to element when specifying the data to
  ;; bind to your email templates, e.g. (:user/username user) below

  ;; These are defaults which you can overwrite in each sender below.
  ;; If you specify :body-data in a sender, it gets merged with the
  ;; map you supply here.
  {:to (:user/email user)
   :body-data {:topic-title (:title topic)
               :topic-id (:id topic)
               :username (:user/username user)}}

  ;; Each sending function can specify additional args. This function
  ;; will take [users topic post]
  (send-reply-notification
   [post]
   :from "custom-f...@for-this-sender.com"
   :subject (str "[Forum Site] Re: " (:title topic))
   :body-data {:content (:content post)
               :formatted-content (markdown-content post)})
  
  (send-new-topic-notification
   []
   :subject (str "[Forum Site] " (:title topic))
   :body-data {:content (:content (:first-post topic))
               :formatted-content (markdown-content (:first-post topic))}))

;; Example of calling
(let [post some-post
      topic (:topic post)
      users (db/all [:users :watching topic])]
  (send-reply-notification users topic post))


Thanks!
Daniel
https://twitter.com/nonrecursive

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to