meta/lib/recycledcloud/accounts/user_notifier.ex
2021-01-12 16:25:27 +01:00

74 lines
1.5 KiB
Elixir

defmodule RecycledCloud.Accounts.UserNotifier do
alias RecycledCloud.Mailer
import Bamboo.Email
defp deliver(to, body) do
_msg = Mailer.template()
|> to(to)
|> subject("Recycled Cloud User Management Notification")
|> text_body(body)
|> Mailer.deliver_now()
{:ok, %{to: to, body: body}}
end
@doc """
Deliver instructions to confirm account.
"""
def deliver_confirmation_instructions(user, url) do
deliver(user.email, """
==============================
Hi #{user.email},
You can confirm your account by visiting the URL below:
#{url}
If you didn't create an account with us, please ignore this.
==============================
""")
end
@doc """
Deliver instructions to reset a user password.
"""
def deliver_reset_password_instructions(user, url) do
deliver(user.email, """
==============================
Hi #{user.email},
You can reset your password by visiting the URL below:
#{url}
If you didn't request this change, please ignore this.
==============================
""")
end
@doc """
Deliver instructions to update a user email.
"""
def deliver_update_email_instructions(user, url) do
deliver(user.email, """
==============================
Hi #{user.email},
You can change your email by visiting the URL below:
#{url}
If you didn't request this change, please ignore this.
==============================
""")
end
end