Email handler using `postal`, Ref. <https://github.com/drewr/postal>.
(handler:postal)
(handler:postal {:keys [postal/conn-opts postal/msg-opts subject-fn body-fn]
:or {subject-fn (signal-subject-fn)
body-fn (utils/format-signal-fn)}})
Experimental, subject to change. Feedback welcome! Needs `postal`, Ref. <https://github.com/drewr/postal>. Returns a (fn handler [signal]) that: - Takes a Telemere signal. - Sends formatted signal string as email to specified recipient. Useful for emailing important alerts to admins, etc. NB can incur financial costs!! See tips section re: protecting against unexpected costs. Options: `:postal/conn-opts` - Map of connection opts provided to `postal` Examples: {:host "mail.isp.net", :user "jsmith", :pass "a-secret"}, {:host "smtp.gmail.com", :user "jsmith@gmail.com", :pass "a-secret" :port 587 :tls true}, {:host "email-smtp.us-east-1.amazonaws.com", :port 587, :tls true :user "AKIAIDTP........" :pass "AikCFhx1P......."} `:postal/msg-opts` - Map of message options Examples: {:from "foo@example.com", :to "bar@example.com"}, {:from "Alice <foo@example.com", :to "Bob <bar@example.com>"}, {:from "no-reply@example.com", :to ["first-responders@example.com", "devops@example.com"], :cc "engineering@example.com" :X-MyHeader "A custom header"} `:subject-fn` - (fn [signal]) => email subject string `:body-fn` - (fn [signal]) => email body content string, see `format-signal-fn` or `pr-signal-fn` Tips: - Sending emails can incur financial costs! Use appropriate dispatch filtering options when calling `add-handler!` to prevent handler from sending unnecessary emails! At least ALWAYS set an appropriate `:rate-limit` option, e.g.: (add-handler! :my-postal-handler (handler:postal {<my-handler-opts}) {:rate-limit {"Max 1 per min" [1 (enc/msecs :mins 1)] "Max 3 per 15 mins" [3 (enc/msecs :mins 15)] "Max 5 per hour" [5 (enc/msecs :hours 1)]}, ...}), etc. - Sending emails is slow! Use appropriate async dispatch options when calling `add-handler!` to prevent handler from blocking signal creator calls, e.g.: (add-handler! :my-postal-handler (handler:postal {<my-handler-opts>}) {:async {:mode :dropping, :buffer-size 128, :n-threads 4} ...}), etc. - Ref. <https://github.com/drewr/postal> for more info on `postal` options.
(signal-subject-fn)
(signal-subject-fn {:keys [max-len subject-signal-key]
:or {max-len 128 subject-signal-key :postal/subject}})
Experimental, subject to change. Returns a (fn format [signal]) that: - Takes a Telemere signal. - Returns a formatted email subject like: "INFO EVENT :taoensso.telemere.postal/ev-id1 - msg"
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close