diff --git a/config/config.exs b/config/config.exs index 25a19e3a..c05ea83b 100644 --- a/config/config.exs +++ b/config/config.exs @@ -9,11 +9,7 @@ import Config config :safira, ecto_repos: [Safira.Repo], - generators: [timestamp_type: :utc_datetime], - from_email_name: System.get_env("FROM_EMAIL_NAME") || "SEI", - from_email_address: System.get_env("FROM_EMAIL_ADDRESS") || "no-reply@seium.org", - umami_script_url: System.get_env("UMAMI_SCRIPT_URL") || "", - umami_website_id: System.get_env("UMAMI_WEBSITE_ID") || "" + generators: [timestamp_type: :utc_datetime] # Flop configuration config :flop, diff --git a/config/runtime.exs b/config/runtime.exs index 32c4e286..1a3ceb76 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -20,6 +20,12 @@ if System.get_env("PHX_SERVER") do config :safira, SafiraWeb.Endpoint, server: true end +config :safira, + from_email_name: System.get_env("FROM_EMAIL_NAME") || "SEI", + from_email_address: System.get_env("FROM_EMAIL_ADDRESS") || "no-reply@seium.org", + umami_script_url: System.get_env("UMAMI_SCRIPT_URL") || "", + umami_website_id: System.get_env("UMAMI_WEBSITE_ID") || "" + if config_env() in [:prod, :stg] do database_url = System.get_env("DATABASE_URL") || diff --git a/lib/safira/accounts/user_notifier.ex b/lib/safira/accounts/user_notifier.ex index f7af43be..f8cdcee5 100644 --- a/lib/safira/accounts/user_notifier.ex +++ b/lib/safira/accounts/user_notifier.ex @@ -6,16 +6,15 @@ defmodule Safira.Accounts.UserNotifier do alias Safira.Mailer - @from_name Application.compile_env!(:safira, :from_email_name) - @from_email Application.compile_env!(:safira, :from_email_address) - # Delivers the email using the application mailer. defp deliver(recipient, subject, body) do + sender = {Mailer.get_sender_name(), Mailer.get_sender_address()} + email = new() |> to(recipient) - |> from({@from_name, @from_email}) - |> subject("[#{@from_name}] #{subject}") + |> from(sender) + |> subject("[#{elem(sender, 0)}] #{subject}") |> text_body(body) with {:ok, _metadata} <- Mailer.deliver(email) do diff --git a/lib/safira/mailer.ex b/lib/safira/mailer.ex index 71ac4afe..c2f5fa9c 100644 --- a/lib/safira/mailer.ex +++ b/lib/safira/mailer.ex @@ -1,3 +1,11 @@ defmodule Safira.Mailer do use Swoosh.Mailer, otp_app: :safira + + def get_sender_name do + Application.get_env(:safira, :from_email_name) + end + + def get_sender_address do + Application.get_env(:safira, :from_email_address) + end end diff --git a/lib/safira_web/components/layouts/landing.html.heex b/lib/safira_web/components/layouts/landing.html.heex index 8fc5b5e5..5601d70b 100644 --- a/lib/safira_web/components/layouts/landing.html.heex +++ b/lib/safira_web/components/layouts/landing.html.heex @@ -15,8 +15,8 @@
diff --git a/lib/safira_web/components/layouts/root.html.heex b/lib/safira_web/components/layouts/root.html.heex index d5762875..1dc21d3d 100644 --- a/lib/safira_web/components/layouts/root.html.heex +++ b/lib/safira_web/components/layouts/root.html.heex @@ -15,8 +15,8 @@