emails: update email templates.

* Add header with the Danbooru name and logo.
* Add footer with links to the site, the privacy policy, and the contact page.
* Add "You received this email because of X" messages to remind users why
  they received the email.
* Add basic CSS to make the design match the site.
This commit is contained in:
evazion
2022-09-27 08:19:13 -05:00
parent 331f15259a
commit e72073ca6b
6 changed files with 114 additions and 59 deletions

View File

@@ -4,7 +4,8 @@ class UserMailer < ApplicationMailer
# The email sent when a user receives a DMail. # The email sent when a user receives a DMail.
def dmail_notice(dmail) def dmail_notice(dmail)
@dmail = dmail @dmail = dmail
mail(dmail.to, require_verified_email: true, subject: "#{Danbooru.config.app_name} - Message received from #{dmail.from.name}") @user = dmail.to
mail(@user, require_verified_email: true, subject: "#{Danbooru.config.app_name}: #{dmail.from.name} sent you a message")
end end
# The email sent when a user requests a password reset. # The email sent when a user requests a password reset.

View File

@@ -0,0 +1,55 @@
<!doctype html>
<html>
<head>
<style>
body {
font-family: "Tahoma", "Verdana", "Helvetica", sans-serif;
font-size: 16px;
padding: 0 1em;
}
a {
color: #0075f8;
text-decoration: none;
}
a:hover {
color: #8caaff;
}
blockquote {
margin-left: 0;
padding-left: 0.5em;
opacity: 0.75;
border-left: 3px solid #d1d1da;
}
.fineprint {
color: #9192a7;
font-size: 12px;
font-style: italic;
}
</style>
</head>
<body style="max-width: 960px; margin: 0 auto;">
<h1 style="text-align: center">
<%= link_to image_tag(image_url("/images/danbooru-logo-96x96.png", host: root_url), width: 36, height: 36, style: "vertical-align: middle"), root_url %>
<%= link_to Danbooru.config.canonical_app_name, root_url %>
</h1>
<%= yield %>
<div style="text-align: center">
<hr>
<p style="font-size: 12px">
<%= link_to image_tag(image_url("/images/danbooru-logo-96x96.png", host: root_url), width: 16, height: 16, style: "vertical-align: middle"), root_url %>
<%= link_to Danbooru.config.canonical_app_name, root_url %> /
<%= link_to "Privacy", privacy_policy_url %> /
<%= link_to "Contact", contact_url %>
<% if content_for(:footer_links).present? %>
<%= yield :footer_links %>
<% end %>
</p>
</div>
</body>
</html>

View File

@@ -1,12 +1,21 @@
<!doctype html> <p>Hi <%= link_to_user @user %>,</p>
<html>
<body> <p><%= link_to_user @dmail.from %> sent you a message on <%= link_to Danbooru.config.canonical_app_name, root_url %>:</p>
<p><%= @dmail.from.name %> said:</p>
<div class="prose" style="margin: 0 2em">
<b><%= @dmail.title %></b>
<div class="prose">
<%= format_text(@dmail.body, base_url: root_url) %> <%= format_text(@dmail.body, base_url: root_url) %>
</div> </div>
<p><%= link_to "View message", dmail_url(@dmail) %> | <%= link_to "Disable notifications", disable_email_notifications_url(@dmail.to) %></p> <%= link_to "Reply", new_dmail_url(respond_to_id: @dmail) %> |
</body> <%= link_to "View message", dmail_url(@dmail) %>
</html>
<p class="fineprint">
You received this email because you chose to receive notifications whenever someone sends you a message on <%= Danbooru.config.canonical_app_name %>.
<%= link_to "Click here", disable_email_notifications_url(@user) %> to unsubscribe from these emails.
</p>
<% content_for(:footer_links) do %>
/ <%= link_to "Unsubscribe", disable_email_notifications_url(@user) %>
<% end %>

View File

@@ -1,20 +1,15 @@
<!doctype html> <h2>Hi <%= link_to_user @user %>,</h2>
<html>
<body>
<h2>Hi <%= @user.name %>,</h2>
<p> <p>
You recently changed your email address on <%= Danbooru.config.app_name %>. You changed your email address on <%= link_to Danbooru.config.canonical_app_name, root_url %>.
Click the link below to verify your new email address. Click the link below to verify your new email address:
</p> </p>
<p> <p style="margin-left: 2em">
<%= link_to "Verify email address", email_verification_url(@user) %> <%= link_to "Verify email address", email_verification_url(@user) %>
</p> </p>
<p> <p class="fineprint">
If you did not recently change your email address on <%= Danbooru.config.app_name %>, You received this email because someone changed their email to this address on <%= link_to Danbooru.config.canonical_app_name, root_url %>. If this
you may delete and ignore this email. wasn't you, you may ignore this email.
</p> </p>
</body>
</html>

View File

@@ -1,19 +1,15 @@
<!doctype html> <h2>Hi <%= link_to_user @user %>,</h2>
<html>
<body>
<p>
You recently requested your <%= Danbooru.config.app_name %> password to be reset.
Click the link below to login to <%= Danbooru.config.app_name %> and reset your password.
</p>
<p> <p>
You requested your <%= link_to Danbooru.config.canonical_app_name, root_url %> password to be reset.
Click the link below to reset your password:
</p>
<p style="margin-left: 2em">
<%= link_to "Reset password", edit_user_password_url(@user, signed_user_id: Danbooru::MessageVerifier.new(:login).generate(@user.id, expires_in: 30.minutes)) %> <%= link_to "Reset password", edit_user_password_url(@user, signed_user_id: Danbooru::MessageVerifier.new(:login).generate(@user.id, expires_in: 30.minutes)) %>
</p> </p>
<p> <p class="fineprint">
If you did not request for your <%= Danbooru.config.app_name %> password to You received this email because someone requested a password reset for your account on <%= link_to Danbooru.config.canonical_app_name, root_url %>.<br>
be reset, please ignore this email or reply to let us know. This link If this wasn't you, you may ignore this email. This link will expire in 30 minutes.
will only be valid for the next 30 minutes.
</p> </p>
</body>
</html>

View File

@@ -1,19 +1,18 @@
<!doctype html> <h2>Hi <%= link_to_user @user %>,</h2>
<html>
<body>
<h2>Hi <%= @user.name %>,</h2>
<p> <p>
Welcome to <%= Danbooru.config.app_name %>! Click the link below to verify your email address. Welcome to <%= link_to Danbooru.config.canonical_app_name, root_url %>! Click the link below to verify your email address:
</p> </p>
<p> <p style="margin-left: 2em">
<%= link_to "Verify email address", email_verification_url(@user) %> <%= link_to "Verify email address", email_verification_url(@user) %>
</p> </p>
<p> <p class="fineprint">
By verifying your email address, you can receive site notifications and you can You received this email because someone signed up for <%= link_to Danbooru.config.canonical_app_name, root_url %> with your address.
recover your account if you ever forget your password. <%= link_to "Click here", disable_email_notifications_url(@user) %> to disable email notifications.
</p> </p>
</body>
</html> <% content_for(:footer_links) do %>
/ <%= link_to "Unsubscribe", disable_email_notifications_url(@user) %>
<% end %>