diff --git a/backend/src/uxbox/config.clj b/backend/src/uxbox/config.clj index 9d2d64616..c985a5cec 100644 --- a/backend/src/uxbox/config.clj +++ b/backend/src/uxbox/config.clj @@ -47,6 +47,7 @@ (s/def ::email-reply-to ::us/email) (s/def ::email-from ::us/email) (s/def ::smtp-host ::us/string) +(s/def ::smtp-port ::us/integer) (s/def ::smtp-user (s/nilable ::us/string)) (s/def ::smtp-password (s/nilable ::us/string)) (s/def ::smtp-tls ::us/boolean) @@ -70,6 +71,7 @@ ::email-reply-to ::email-from ::smtp-host + ::smtp-port ::smtp-user ::smtp-password ::smtp-tls diff --git a/backend/src/uxbox/services/mutations/profile.clj b/backend/src/uxbox/services/mutations/profile.clj index a26e53aa0..3a1d9ccb9 100644 --- a/backend/src/uxbox/services/mutations/profile.clj +++ b/backend/src/uxbox/services/mutations/profile.clj @@ -254,7 +254,7 @@ (let [data {:to (:email params) :name (:fullname params)}] (p/do! - (emails/send! emails/register data) + (emails/send! conn emails/register data) profile)))))) ;; --- Mutation: Request Profile Recovery diff --git a/backend/src/uxbox/tasks/impl.clj b/backend/src/uxbox/tasks/impl.clj index 2b4b062d4..337525bb0 100644 --- a/backend/src/uxbox/tasks/impl.clj +++ b/backend/src/uxbox/tasks/impl.clj @@ -102,6 +102,13 @@ (cond-> row props (assoc :props (blob/decode props))))) +(defn- log-error + [item err] + (log/error "Unhandled exception on task '" (:name item) + "' (retry:" (:retry-num item) ") \n" + (with-out-str + (.printStackTrace ^Throwable err (java.io.PrintWriter. *out*))))) + (defn- event-loop [{:keys [tasks] :as options}] (let [queue (:queue options "default") @@ -114,9 +121,11 @@ (-> (p/do! (handle-task tasks item)) (p/handle (fn [v e] (if e - (if (>= (:retry-num item) max-retries) - (mark-as-failed conn item e) - (reschedule conn item e)) + (do + (log-error item e) + (if (>= (:retry-num item) max-retries) + (mark-as-failed conn item e) + (reschedule conn item e))) (mark-as-completed conn item)))) (p/then' (constantly ::handled)))))))))) diff --git a/backend/src/uxbox/tasks/sendmail.clj b/backend/src/uxbox/tasks/sendmail.clj index c4b29ebb7..80908aa9f 100644 --- a/backend/src/uxbox/tasks/sendmail.clj +++ b/backend/src/uxbox/tasks/sendmail.clj @@ -13,6 +13,7 @@ [clojure.tools.logging :as log] [cuerdas.core :as str] [postal.core :as postal] + [vertx.core :as vc] [promesa.core :as p] [uxbox.common.exceptions :as ex] [uxbox.config :as cfg] @@ -48,16 +49,16 @@ (defn send-email [email] - (p/future - (let [config (get-smtp-config cfg/config) - result (if (:enabled config) - (postal/send-message config email) - (send-email-to-console email))] - (when (not= (:error result) :SUCCESS) - (ex/raise :type :sendmail-error - :code :email-not-sent - :context result)) - nil))) + (vc/blocking + (let [config (get-smtp-config cfg/config) + result (if (:enabled config) + (postal/send-message config email) + (send-email-to-console email))] + (when (not= (:error result) :SUCCESS) + (ex/raise :type :sendmail-error + :code :email-not-sent + :context result)) + nil))) (defn handler {:uxbox.tasks/name "sendmail"}