 (defn send-new-user-email
   "Format and Send an welcome email for newly created users."
   [invited invitor join-url]
-  (let [data-quote (rand-nth q/quotations)
-        company (or (setting/get :site-name)
-                    "Unknown")
-        message-body (->> {:invitedName (:first_name invited)
-                           :invitorName (:first_name invitor)
-                           :invitorEmail (:email invitor)
-                           :company company
-                           :joinUrl join-url
-                           :quotation (:quote data-quote)
-                           :quotationAuthor (:author data-quote)
-                           :today (u/format-date "MMM'&nbsp;'dd,'&nbsp;'yyyy" (System/currentTimeMillis))}
-                          (stencil/render-file "metabase/email/new_user_invite"))]
+  (let [data-quote   (rand-nth q/quotations)
+        company      (or (setting/get :site-name) "Unknown")
+        message-body (stencil/render-file "metabase/email/new_user_invite"
+                                          {:invitedName (:first_name invited)
+                                           :invitorName (:first_name invitor)
+                                           :invitorEmail (:email invitor)
+                                           :company company
+                                           :joinUrl join-url
+                                           :quotation (:quote data-quote)
+                                           :quotationAuthor (:author data-quote)
+                                           :today (u/format-date "MMM'&nbsp;'dd,'&nbsp;'yyyy" (System/currentTimeMillis))})]
     (email/send-message
       :subject     (str "You're invited to join " company "'s Metabase")
       :recipients   [(:email invited)]

         (u/is-email? email)
         (string? hostname)
         (string? password-reset-url)]}
  (let [message-body (->> {:hostname hostname
                           :passwordResetUrl password-reset-url}
                          (stencil/render-file "metabase/email/password_reset"))]
    (email/send-message
     :subject      "[Metabase] Password Reset Request"
     :recipients   [email]

(defn render-pulse-email
  "Take a pulse object and list of results, returns an array of attachment objects for an email"
  [pulse results]
  (let [images       (atom [])
        render-img   (fn [bytes] (reset! images (conj @images bytes)) (str "cid:IMAGE_" (-> @images count dec)))
        body         (apply vector :div (mapv (partial render-pulse-section render-img) results))
        data-quote   (rand-nth q/quotations)
        message-body (stencil/render-file "metabase/email/pulse"
                                          {:pulse (html body)
                                           :pulseName (:name pulse)
                                           :sectionStype p/section-style
                                           :colorGrey4 p/color-grey-4
                                           :quotation (:quote data-quote)
                                           :quotationAuthor (:author data-quote)})]
    (apply vector {:type "text/html" :content message-body}
                  (map-indexed (fn [idx bytes] {:type :inline
                                                :content-id (str "IMAGE_" idx)
