2020-01-26 21:36:50 +01:00
|
|
|
defmodule Mobilizon.Web.Email.Mailer do
|
2018-10-11 17:37:39 +02:00
|
|
|
@moduledoc """
|
2019-09-07 23:58:53 +02:00
|
|
|
Mobilizon Mailer.
|
2018-10-11 17:37:39 +02:00
|
|
|
"""
|
|
|
|
use Bamboo.Mailer, otp_app: :mobilizon
|
2021-06-27 13:15:24 +02:00
|
|
|
alias Mobilizon.Service.ErrorReporting.Sentry
|
2021-04-20 15:02:24 +02:00
|
|
|
|
2021-09-10 11:27:59 +02:00
|
|
|
@spec send_email_later(Bamboo.Email.t()) :: Bamboo.Email.t()
|
2021-04-20 15:02:24 +02:00
|
|
|
def send_email_later(email) do
|
2021-04-20 15:27:33 +02:00
|
|
|
Mobilizon.Web.Email.Mailer.deliver_later!(email)
|
|
|
|
rescue
|
|
|
|
error ->
|
|
|
|
Sentry.capture_exception(error,
|
|
|
|
stacktrace: __STACKTRACE__,
|
|
|
|
extra: %{extra: "Error while sending email"}
|
|
|
|
)
|
2021-04-20 15:02:24 +02:00
|
|
|
|
2021-04-20 15:27:33 +02:00
|
|
|
reraise error, __STACKTRACE__
|
2021-04-20 15:02:24 +02:00
|
|
|
end
|
|
|
|
|
2021-09-10 11:27:59 +02:00
|
|
|
@spec send_email(Bamboo.Email.t()) :: Bamboo.Email.t() | {Bamboo.Email.t(), any()}
|
2021-04-20 15:02:24 +02:00
|
|
|
def send_email(email) do
|
2021-04-20 15:27:33 +02:00
|
|
|
Mobilizon.Web.Email.Mailer.deliver_now!(email)
|
|
|
|
rescue
|
|
|
|
error ->
|
|
|
|
Sentry.capture_exception(error,
|
|
|
|
stacktrace: __STACKTRACE__,
|
|
|
|
extra: %{extra: "Error while sending email"}
|
|
|
|
)
|
2021-04-20 15:02:24 +02:00
|
|
|
|
2021-04-20 15:27:33 +02:00
|
|
|
reraise error, __STACKTRACE__
|
2021-04-20 15:02:24 +02:00
|
|
|
end
|
2018-10-11 17:37:39 +02:00
|
|
|
end
|