Skip to content
Snippets Groups Projects
Commit 7f879782 authored by Cam Saül's avatar Cam Saül
Browse files

send-message -> send-message!

parent f9e50ae0
No related branches found
No related tags found
No related merge requests found
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
"Send a test email. You must be a superuser to do this." "Send a test email. You must be a superuser to do this."
[] []
(check-superuser) (check-superuser)
(let [response (email/send-message (let [response (email/send-message!
:subject "Metabase Test Email" :subject "Metabase Test Email"
:recipients [(:email @*current-user*)] :recipients [(:email @*current-user*)]
:message-type :text :message-type :text
......
...@@ -35,11 +35,11 @@ ...@@ -35,11 +35,11 @@
[] []
(not (s/blank? (setting/get :email-smtp-host)))) (not (s/blank? (setting/get :email-smtp-host))))
(defn send-message (defn send-message!
"Send an email to one or more RECIPIENTS. "Send an email to one or more RECIPIENTS.
RECIPIENTS is a sequence of email addresses; MESSAGE-TYPE must be either `:text` or `:html`. RECIPIENTS is a sequence of email addresses; MESSAGE-TYPE must be either `:text` or `:html`.
(email/send-message (email/send-message!
:subject \"[Metabase] Password Reset Request\" :subject \"[Metabase] Password Reset Request\"
:recipients [\"cam@metabase.com\"] :recipients [\"cam@metabase.com\"]
:message-type :text :message-type :text
...@@ -95,8 +95,8 @@ ...@@ -95,8 +95,8 @@
{:pre [(string? host) {:pre [(string? host)
(integer? port)]} (integer? port)]}
(try (try
(let [ssl (= security "ssl") (let [ssl? (= security "ssl")
proto (if ssl "smtps" "smtp") proto (if ssl? "smtps" "smtp")
details (-> details details (-> details
(assoc :proto proto (assoc :proto proto
:connectiontimeout "1000" :connectiontimeout "1000"
...@@ -112,6 +112,6 @@ ...@@ -112,6 +112,6 @@
{:error :SUCCESS {:error :SUCCESS
:message nil} :message nil}
(catch Throwable e (catch Throwable e
(println "err" (.getMessage e)) (log/error "Error testing SMTP connection:" (.getMessage e))
{:error :ERROR {:error :ERROR
:message (.getMessage e)}))) :message (.getMessage e)})))
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
:quotationAuthor (:author data-quote) :quotationAuthor (:author data-quote)
:today (u/format-date "MMM' 'dd,' 'yyyy") :today (u/format-date "MMM' 'dd,' 'yyyy")
:logoHeader true})] :logoHeader true})]
(email/send-message (email/send-message!
:subject (str "You're invited to join " company "'s Metabase") :subject (str "You're invited to join " company "'s Metabase")
:recipients [(:email invited)] :recipients [(:email invited)]
:message-type :html :message-type :html
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
(and (map? invitor) (and (map? invitor)
(u/is-email? (:email invitor))))]} (u/is-email? (:email invitor))))]}
(let [data-quote (quotation/random-quote)] (let [data-quote (quotation/random-quote)]
(email/send-message (email/send-message!
:subject (format (if google-auth? :subject (format (if google-auth?
"%s created a Metabase account" "%s created a Metabase account"
"%s accepted your Metabase invite") "%s accepted your Metabase invite")
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
:sso google-auth? :sso google-auth?
:passwordResetUrl password-reset-url :passwordResetUrl password-reset-url
:logoHeader true})] :logoHeader true})]
(email/send-message (email/send-message!
:subject "[Metabase] Password Reset Request" :subject "[Metabase] Password Reset Request"
:recipients [email] :recipients [email]
:message-type :html :message-type :html
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
:quotation (:quote data-quote) :quotation (:quote data-quote)
:quotationAuthor (:author data-quote))) :quotationAuthor (:author data-quote)))
message-body (stencil/render-file "metabase/email/notification" context)] message-body (stencil/render-file "metabase/email/notification" context)]
(email/send-message (email/send-message!
:subject "[Metabase] Notification" :subject "[Metabase] Notification"
:recipients [email] :recipients [email]
:message-type :html :message-type :html
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
:callToAction "Would you mind taking a fast 6 question survey to tell us how it’s going?" :callToAction "Would you mind taking a fast 6 question survey to tell us how it’s going?"
:link "http://www.metabase.com/feedback/active"})) :link "http://www.metabase.com/feedback/active"}))
message-body (stencil/render-file "metabase/email/follow_up_email" context)] message-body (stencil/render-file "metabase/email/follow_up_email" context)]
(email/send-message (email/send-message!
:subject subject :subject subject
:recipients [email] :recipients [email]
:message-type :html :message-type :html
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
(log/debug (format "Sending Pulse (%d: %s) via Channel :email" id name)) (log/debug (format "Sending Pulse (%d: %s) via Channel :email" id name))
(let [email-subject (str "Pulse: " name) (let [email-subject (str "Pulse: " name)
email-recipients (filterv u/is-email? (map :email recipients))] email-recipients (filterv u/is-email? (map :email recipients))]
(email/send-message (email/send-message!
:subject email-subject :subject email-subject
:recipients email-recipients :recipients email-recipients
:message-type :attachments :message-type :attachments
......
...@@ -32,16 +32,3 @@ ...@@ -32,16 +32,3 @@
new-settings (email-settings) new-settings (email-settings)
_ (setting/set-many! orig-settings)] _ (setting/set-many! orig-settings)]
new-settings)) new-settings))
;; with-fake-inbox doesn't work in this case because of the api call
;; /api/email/test - sends a test email to the given user
;(expect
; [{:from "notifications@metabase.com",
; :to [(-> (fetch-user :crowberto) :email)],
; :subject "Metabase Test Email",
; :body [{:type "text/plain; charset=utf-8"
; :content "Your Metabase emails are working — hooray!"}]}]
; (with-fake-inbox
; ((user->client :crowberto) :post 200 "email/test")
; (@inbox (-> (fetch-user :crowberto) :email))))
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
:body [{:type "text/html; charset=utf-8" :body [{:type "text/html; charset=utf-8"
:content "101. Metabase will make you a better person"}]}] :content "101. Metabase will make you a better person"}]}]
(with-fake-inbox (with-fake-inbox
(email/send-message (email/send-message!
:subject "101 Reasons to use Metabase" :subject "101 Reasons to use Metabase"
:recipients ["test@test.com"] :recipients ["test@test.com"]
:message-type :html :message-type :html
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment