Email handler using `postal`, Ref. <https://github.com/drewr/postal>.
(handler:postal {:keys [conn-opts msg-opts subject-fn subject-max-len body-fn]
:or {body-fn (utils/format-signal-fn)
subject-fn (utils/signal-preamble-fn {:format-inst-fn
nil})
subject-max-len 128}})
Experimental, subject to change. Needs `postal`, Ref. <https://github.com/drewr/postal>. Returns a signal handler that: - Takes a Telemere signal (map). - Sends the signal as an email to specified recipient. Useful for emailing important alerts to admins, etc. Default handler dispatch options (override when calling `add-handler!`): `:min-level` - `:info` `:rate-limit` - [[5 (enc/msecs :mins 1)] ; Max 5 emails in 1 min [10 (enc/msecs :mins 15)] ; Max 10 emails in 15 mins [15 (enc/msecs :hours 1)] ; Max 15 emails in 1 hour [30 (enc/msecs :hours 6)] ; Max 30 emails in 6 hours ] Options: `:conn-opts` - Map of connection opts given to `postal/send-message` 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......."} `:msg-opts` - Map of message opts given to `postal/send-message` 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 `:subject-max-len` - Truncate subjects beyond this length (default 90) `:body-fn` - (fn [signal]) => email body content string, see `format-signal-fn` or `pr-signal-fn` Tips: - Ref. <https://github.com/drewr/postal> for more info on `postal` options. - Sending emails can be slow, and can incur financial costs! Use appropriate handler dispatch options for async handling and rate limiting, etc.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close