add send test email button to campaign form
All checks were successful
deploy / deploy (push) Successful in 1m22s
All checks were successful
deploy / deploy (push) Successful in 1m22s
Sends the campaign to the admin's own email address as a preview, with [Test] prefix in subject line. Uses the same HTML template and formatting as real sends. Does not affect campaign status or sent counts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,27 @@ defmodule Berrypod.Newsletter.Notifier do
|
||||
deliver(subscriber.email, "Confirm your subscription", text, html)
|
||||
end
|
||||
|
||||
@doc "Sends a test/preview email of a campaign to the given address."
|
||||
def deliver_test(campaign, to_email) do
|
||||
shop_name = Berrypod.Settings.get_setting("shop_name", "Berrypod")
|
||||
sample_unsub = BerrypodWeb.Endpoint.url() <> "/unsubscribe/test-preview"
|
||||
|
||||
body_with_url =
|
||||
String.replace(campaign.body, "{{unsubscribe_url}}", sample_unsub)
|
||||
|
||||
text = """
|
||||
[TEST] #{body_with_url}
|
||||
|
||||
---
|
||||
This is a test email. No subscribers received this.
|
||||
"""
|
||||
|
||||
html_content = text_to_html(body_with_url, sample_unsub)
|
||||
html = wrap_html(shop_name, html_content, sample_unsub)
|
||||
|
||||
deliver(to_email, "[Test] #{campaign.subject}", text, html)
|
||||
end
|
||||
|
||||
@doc "Sends a campaign email to a single subscriber."
|
||||
def deliver_campaign(campaign, subscriber) do
|
||||
shop_name = Berrypod.Settings.get_setting("shop_name", "Berrypod")
|
||||
|
||||
Reference in New Issue
Block a user