🐛 Fix sendmail to console unexpected exception.

This commit is contained in:
Andrey Antukh 2020-11-11 13:34:06 +01:00
parent c3ca59ac93
commit ef01caf829
2 changed files with 10 additions and 9 deletions

View file

@ -17,9 +17,9 @@
[app.metrics :as mtx]))
(defn- send-console!
[cfg email]
[config email]
(let [baos (java.io.ByteArrayOutputStream.)
mesg (emails/smtp-message cfg email)]
mesg (emails/smtp-message config email)]
(.writeTo mesg baos)
(let [out (with-out-str
(println "email console dump:")
@ -31,10 +31,10 @@
(defn handler
{:app.tasks/name "sendmail"}
[{:keys [props] :as task}]
(if (:smtp-enable cfg/config)
(-> (cfg/smtp cfg/config)
(emails/send! props))
(send-console! props)))
(let [config (cfg/smtp cfg/config)]
(if (:enabled config)
(emails/send! config props)
(send-console! config props))))
(mtx/instrument-with-summary!
{:var #'handler