diff --git a/lib/send_it/marketing/message_notifier.ex b/lib/send_it/marketing/message_notifier.ex index f4a7279..65aeaf7 100644 --- a/lib/send_it/marketing/message_notifier.ex +++ b/lib/send_it/marketing/message_notifier.ex @@ -10,10 +10,10 @@ defmodule SendIt.Marketing.MessageNotifier do @from_email "newsletter@ptcoffee.com" def deliver_message(message) do - message.contacts - |> format_recipients() - |> dbg() - |> deliver(message.subject, message.content) + contacts = message.contacts |> format_recipients() + body = message.content |> format_body() + + deliver(contacts, message.subject, body) end defp deliver(recipients, subject, body) do @@ -22,10 +22,7 @@ defmodule SendIt.Marketing.MessageNotifier do to: recipients, from: {@from_name, @from_email}, subject: subject, - html_body: - body - |> Phoenix.HTML.html_escape() - |> Phoenix.HTML.safe_to_string() + html_body: body ) |> put_provider_option(:recipient_vars, format_recipient_vars(recipients)) @@ -48,4 +45,25 @@ defmodule SendIt.Marketing.MessageNotifier do Map.put_new(acc, email, %{name: name}) end) end + + defp format_body(content) do + content + |> add_unsubscription() + end + + defp add_unsubscription(content) do + url = url(~p"/subscription") + + """ + #{content} +
+
+ +
+

+ Unsubscribe
+ If you no longer wish to receive our emails, you can unsubscribe here. +

+ """ + end end