mx.interware.caudal.io.email

email-event

(email-event smtp-opts msg-opts events & [keys html-template])

Sends an event or a sequence of events via email

  • smtp-opts SMTP options passed to Postal to send the email
  • msg-opts Message options passed to Postal to send the email. Value of :body is replaced with HTML produced by make-header, event->html and make-footer
  • events to be sended
  • keys (optional) keys to be sended
  • html-template (optional) to produce a representation of an event

event->html

(event->html caudal-event & [html-template])

Produces a HTML representation of an event

  • caudal-event to be represented in HTML
  • html-template (optional) to produce a representation of an event. This template uses vectors to represent elements and is parsed using Hiccup and replaces caudal-event key ocurrences into vectors with its value

mailer

(mailer [smtp-opts msg-opts & [keys html-template]] & children)

Returns a mailer, which is a function invoked with a map of options and returns a stream that takes a single or a sequence of events, and sends an email about them.

Examples:

;; Mailer that uses a local sendmail
(def email (mailer))

;; Mailer with Postal options  
(def email (mailer {:host 'smtp.gmail.com' 
                    :user 'sample@gmail.com'
                    :pass 'somesecret'}
                   {:subject 'Help!!'
                    :to ['ops@example.com' 'support@example.com']
                    :ssl :yes}))

;; Invoking email sending only :message and :ts fields
(email event [:message :ts])

;; Invoking email sending only :message and :ts fields into a custom template
(email event [:message :ts] [:p [:em :message] ' since ' [:i :ts]])

;; Sends max 5 email each 15 minutes using rollup
 (stateful/rollup :host 5 (* 60000 15)
    (mailer smtp-opts))

make-header

(make-header title)

Creates a default header with a simple title

  • title replaced in mail header

make-table-template

(make-table-template source)

Creates a default html view from an arbitrary source map

  • source arbitrary map to build a template