use shop_name and email_from_address settings for all outbound emails
All checks were successful
deploy / deploy (push) Successful in 1m22s
All checks were successful
deploy / deploy (push) Successful in 1m22s
All three notifier functions (order confirmation, shipping, cart recovery) now read from the same two settings rather than using hardcoded values or duplicating the lookup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
61887b9d5b
commit
fd355c3397
@ -98,8 +98,6 @@ defmodule Berrypod.Orders.OrderNotifier do
|
|||||||
Plain text, no tracking pixels, single send. Includes an unsubscribe link.
|
Plain text, no tracking pixels, single send. Includes an unsubscribe link.
|
||||||
"""
|
"""
|
||||||
def deliver_cart_recovery(cart, order, unsubscribe_url) do
|
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()
|
base_url = BerrypodWeb.Endpoint.url()
|
||||||
|
|
||||||
body = """
|
body = """
|
||||||
@ -118,33 +116,19 @@ defmodule Berrypod.Orders.OrderNotifier do
|
|||||||
==============================
|
==============================
|
||||||
"""
|
"""
|
||||||
|
|
||||||
email =
|
deliver(cart.customer_email, "You left something behind", body)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# --- Private ---
|
# --- Private ---
|
||||||
|
|
||||||
defp deliver(recipient, subject, body) do
|
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 =
|
email =
|
||||||
new()
|
new()
|
||||||
|> to(recipient)
|
|> to(recipient)
|
||||||
|> from({"Berrypod", "contact@example.com"})
|
|> from({shop_name, from_address})
|
||||||
|> subject(subject)
|
|> subject(subject)
|
||||||
|> text_body(body)
|
|> text_body(body)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user