analytics/lib/plausible_web/email.ex

116 lines
3.3 KiB
Elixir
Raw Normal View History

2019-09-02 14:29:19 +03:00
defmodule PlausibleWeb.Email do
use Bamboo.Phoenix, view: PlausibleWeb.EmailView
import Bamboo.PostmarkHelper
def activation_email(user, link) do
new_email()
|> to(user.email)
|> from("Uku Taht <uku@plausible.io>")
|> tag("activation-email")
|> subject("Activate your Plausible free trial")
|> render("activation_email.html", name: user.name, link: link)
end
2019-09-02 14:29:19 +03:00
def welcome_email(user) do
new_email()
|> to(user)
|> from("Uku Taht <uku@plausible.io>")
|> tag("welcome-email")
|> subject("Welcome to Plausible")
2019-09-02 14:29:19 +03:00
|> render("welcome_email.html", user: user)
end
def create_site_email(user) do
new_email()
|> to(user)
|> from("Uku Taht <uku@plausible.io>")
|> tag("create-site-email")
|> subject("Your Plausible setup: Add your website details")
|> render("create_site_email.html", user: user)
end
def site_setup_help(user, site) do
2019-09-02 14:29:19 +03:00
new_email()
|> to(user)
|> from("Uku Taht <uku@plausible.io>")
|> tag("help-email")
|> subject("Your Plausible setup: Waiting for the first page views")
|> render("site_setup_help_email.html", user: user, site: site)
end
def site_setup_success(user, site) do
new_email()
|> to(user)
|> from("Uku Taht <uku@plausible.io>")
|> tag("setup-success-email")
|> subject("Plausible is now tracking your website stats")
|> render("site_setup_success_email.html", user: user, site: site)
end
def check_stats_email(user) do
new_email()
|> to(user)
|> from("Uku Taht <uku@plausible.io>")
|> tag("check-stats-email")
|> subject("Check your Plausible website stats")
|> render("check_stats_email.html", user: user)
2019-09-02 14:29:19 +03:00
end
def password_reset_email(email, reset_link) do
new_email()
|> to(email)
|> from("Uku Taht <uku@plausible.io>")
|> tag("password-reset-email")
|> subject("Plausible password reset")
|> render("password_reset_email.html", reset_link: reset_link)
end
def trial_one_week_reminder(user) do
2019-09-02 14:29:19 +03:00
new_email()
|> to(user)
|> from("Uku Taht <uku@plausible.io>")
|> tag("trial-one-week-reminder")
2020-03-24 16:29:44 +03:00
|> subject("Your Plausible trial expires next week")
|> render("trial_one_week_reminder.html", user: user)
2019-09-02 14:29:19 +03:00
end
def trial_upgrade_email(user, day, pageviews) do
new_email()
|> to(user)
|> from("Uku Taht <uku@plausible.io>")
|> tag("trial-upgrade-email")
|> subject("Your Plausible trial ends #{day}")
|> render("trial_upgrade_email.html", user: user, day: day, pageviews: pageviews)
end
def trial_over_email(user) do
new_email()
|> to(user)
|> from("Uku Taht <uku@plausible.io>")
|> tag("trial-over-email")
|> subject("Your Plausible trial has ended")
|> render("trial_over_email.html", user: user)
end
def feedback(from, text) do
from = if from == "", do: "anonymous@plausible.io", else: from
new_email()
|> to("uku@plausible.io")
|> from("feedback@plausible.io")
|> put_param("ReplyTo", from)
|> tag("feedback")
|> subject("New feedback submission")
|> text_body(text)
end
2019-09-05 19:11:07 +03:00
def weekly_report(email, site, assigns) do
new_email()
|> to(email)
2019-09-23 15:40:12 +03:00
|> from("Plausible Insights <info@plausible.io>")
2019-09-05 19:11:07 +03:00
|> tag("weekly-report")
|> subject("#{assigns[:name]} report for #{site.domain}")
2019-09-05 19:11:07 +03:00
|> render("weekly_report.html", Keyword.put(assigns, :site, site))
end
2019-09-02 14:29:19 +03:00
end