From a9f443766e53e14d941a37f2737c05cf21aafb76 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Thu, 3 Aug 2017 19:08:38 +0200 Subject: [PATCH] Send HTML emails --- lib/asciinema/email.ex | 3 +++ lib/asciinema_web/templates/email/login.html.eex | 10 ++++++++++ lib/asciinema_web/templates/email/signup.html.eex | 10 ++++++++++ lib/asciinema_web/templates/layout/email.html.eex | 9 +++++++++ 4 files changed, 32 insertions(+) create mode 100644 lib/asciinema_web/templates/email/login.html.eex create mode 100644 lib/asciinema_web/templates/email/signup.html.eex create mode 100644 lib/asciinema_web/templates/layout/email.html.eex diff --git a/lib/asciinema/email.ex b/lib/asciinema/email.ex index fa9329a..6264af3 100644 --- a/lib/asciinema/email.ex +++ b/lib/asciinema/email.ex @@ -7,6 +7,7 @@ defmodule Asciinema.Email do |> to(email_address) |> subject("Welcome to #{instance_hostname()}") |> render("signup.text", signup_url: signup_url) + |> render("signup.html", signup_url: signup_url) end def login_email(email_address, login_url) do @@ -14,12 +15,14 @@ defmodule Asciinema.Email do |> to(email_address) |> subject("Login request") |> render("login.text", login_url: login_url) + |> render("login.html", login_url: login_url) end defp base_email do new_email() |> from({"asciinema", from_address()}) |> put_header("Reply-To", reply_to_address()) + |> put_html_layout({AsciinemaWeb.LayoutView, "email.html"}) end defp from_address do diff --git a/lib/asciinema_web/templates/email/login.html.eex b/lib/asciinema_web/templates/email/login.html.eex new file mode 100644 index 0000000..d24d81b --- /dev/null +++ b/lib/asciinema_web/templates/email/login.html.eex @@ -0,0 +1,10 @@ +

Hello,

+ +

Click the following link to log in to asciinema.org:

+ +

<%= @login_url %>

+ +

+
+ If you did not initiate this request, just ignore this email. The request will expire shortly. +

diff --git a/lib/asciinema_web/templates/email/signup.html.eex b/lib/asciinema_web/templates/email/signup.html.eex new file mode 100644 index 0000000..287b929 --- /dev/null +++ b/lib/asciinema_web/templates/email/signup.html.eex @@ -0,0 +1,10 @@ +

Welcome,

+ +

Click the following link to create your account at asciinema.org:

+ +

<%= @signup_url %>

+ +

+
+ If you did not initiate this request, just ignore this email. The request will expire shortly. +

diff --git a/lib/asciinema_web/templates/layout/email.html.eex b/lib/asciinema_web/templates/layout/email.html.eex new file mode 100644 index 0000000..e91c806 --- /dev/null +++ b/lib/asciinema_web/templates/layout/email.html.eex @@ -0,0 +1,9 @@ + + + + + + + <%= render @view_module, @view_template, assigns %> + +