prop/lib/microwaveprop/accounts/user_notifier.ex
Graham McIntire d6e9d80ce9 Send mail as prop@w5isp.com with reply-to graham@mcintire.me
Centralized the From and Reply-To headers in Microwaveprop.Mailer.apply_defaults/1
so UserNotifier and EditNotifier can't drift. Drops the EMAIL_FROM env var
override — both values are hardcoded now.
2026-04-12 14:00:38 -05:00

62 lines
1.4 KiB
Elixir

defmodule Microwaveprop.Accounts.UserNotifier do
@moduledoc false
import Swoosh.Email
alias Microwaveprop.Mailer
# Delivers the email using the application mailer.
defp deliver(recipient, subject, body) do
email =
new()
|> to(recipient)
|> Mailer.apply_defaults()
|> subject(subject)
|> text_body(body)
with {:ok, _metadata} <- Mailer.deliver(email) do
{:ok, email}
end
end
@doc """
Deliver instructions to confirm a newly registered account.
"""
def deliver_confirmation_instructions(user, url) do
deliver(user.email, "Confirm your NTMS Propagation account", """
==============================
Hi #{user.callsign},
Welcome to the NTMS Propagation tool. To finish creating your
account, please confirm your email by visiting the URL below:
#{url}
This link expires in 24 hours. If you didn't create this account,
please ignore this message.
==============================
""")
end
@doc """
Deliver instructions to update a user email.
"""
def deliver_update_email_instructions(user, url) do
deliver(user.email, "Update email instructions", """
==============================
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