diff --git a/lib/berrypod/orders/order_notifier.ex b/lib/berrypod/orders/order_notifier.ex index 0440bb3..877e140 100644 --- a/lib/berrypod/orders/order_notifier.ex +++ b/lib/berrypod/orders/order_notifier.ex @@ -98,8 +98,6 @@ defmodule Berrypod.Orders.OrderNotifier do Plain text, no tracking pixels, single send. Includes an unsubscribe link. """ def deliver_cart_recovery(cart, order, unsubscribe_url) do - from_address = Berrypod.Settings.get_setting("email_from_address", "contact@example.com") - subject = "You left something behind" base_url = BerrypodWeb.Endpoint.url() body = """ @@ -118,33 +116,19 @@ defmodule Berrypod.Orders.OrderNotifier do ============================== """ - email = - new() - |> to(cart.customer_email) - |> from(from_address) - |> subject(subject) - |> text_body(body) - - case Mailer.deliver(email) do - {:ok, _metadata} = result -> - result - - {:error, reason} = error -> - Logger.warning( - "Failed to send cart recovery email to #{cart.customer_email}: #{inspect(reason)}" - ) - - error - end + deliver(cart.customer_email, "You left something behind", body) end # --- Private --- defp deliver(recipient, subject, body) do + shop_name = Berrypod.Settings.get_setting("shop_name", "Berrypod") + from_address = Berrypod.Settings.get_setting("email_from_address", "contact@example.com") + email = new() |> to(recipient) - |> from({"Berrypod", "contact@example.com"}) + |> from({shop_name, from_address}) |> subject(subject) |> text_body(body)