34 lines
1.2 KiB
Elixir
34 lines
1.2 KiB
Elixir
defmodule MvWeb.Emails.JoinConfirmationEmail do
|
|
@moduledoc """
|
|
Sends the join request confirmation email (double opt-in) using the unified email layout.
|
|
"""
|
|
use MvWeb, :verified_routes
|
|
use Gettext, backend: MvWeb.Gettext, otp_app: :mv
|
|
|
|
alias MvWeb.Emails.JoinEmail
|
|
|
|
@doc """
|
|
Sends the join confirmation email to the given address with the confirmation link.
|
|
|
|
Uses the same SMTP configuration as the test mail (Settings or boot ENV) via
|
|
`Mailer.deliver/2` with `Mailer.smtp_config/0` for consistency.
|
|
|
|
Called from the domain after a JoinRequest is created (submit flow) or when
|
|
resending to an existing pending request.
|
|
|
|
## Options
|
|
- `:resend` - If true, adds a short note that the link is being sent again for an existing request.
|
|
|
|
Returns `{:ok, email}` on success, `{:error, reason}` on delivery failure.
|
|
"""
|
|
def send(email_address, token, opts \\ [])
|
|
when is_binary(email_address) and is_binary(token) do
|
|
confirm_url = url(~p"/confirm_join/#{token}")
|
|
subject = gettext("Confirm your membership request")
|
|
|
|
JoinEmail.deliver(email_address, "join_confirmation.html", subject, %{
|
|
confirm_url: confirm_url,
|
|
resend: Keyword.get(opts, :resend, false)
|
|
})
|
|
end
|
|
end
|