1 defmodule Pleroma.UserEmail do
2 @moduledoc "User emails"
6 alias Pleroma.Web.{Endpoint, Router}
8 defp instance_config, do: Pleroma.Config.get(:instance)
10 defp instance_name, do: instance_config()[:name]
13 {instance_name(), instance_config()[:email]}
16 defp recipient(email, nil), do: email
17 defp recipient(email, name), do: {name, email}
18 defp recipient(%Pleroma.User{} = user), do: recipient(user.email, user.name)
20 def password_reset_email(user, password_reset_token) when is_binary(password_reset_token) do
22 Router.Helpers.util_url(
29 <h3>Reset your password at #{instance_name()}</h3>
30 <p>Someone has requested password change for your account at #{instance_name()}.</p>
31 <p>If it was you, visit the following link to proceed: <a href="#{password_reset_url}">reset password</a>.</p>
32 <p>If it was someone else, nothing to worry about: your data is secure and your password has not been changed.</p>
36 |> to(recipient(user))
38 |> subject("Password reset")
39 |> html_body(html_body)
42 def user_invitation_email(
44 %Pleroma.UserInviteToken{} = user_invite_token,
49 Router.Helpers.redirect_url(
52 user_invite_token.token
56 <h3>You are invited to #{instance_name()}</h3>
57 <p>#{user.name} invites you to join #{instance_name()}, an instance of Pleroma federated social networking platform.</p>
58 <p>Click the following link to register: <a href="#{registration_url}">accept invitation</a>.</p>
62 |> to(recipient(to_email, to_name))
64 |> subject("Invitation to #{instance_name()}")
65 |> html_body(html_body)
68 def account_confirmation_email(user) do
70 Router.Helpers.confirm_email_url(
73 to_string(user.info.confirmation_token)
77 <h3>Welcome to #{instance_name()}!</h3>
78 <p>Email confirmation is required to activate the account.</p>
79 <p>Click the following link to proceed: <a href="#{confirmation_url}">activate your account</a>.</p>
83 |> to(recipient(user))
85 |> subject("#{instance_name()} account confirmation")
86 |> html_body(html_body)