mitgliederverwaltung/lib/mv/mailer.ex

30 lines
989 B
Elixir

defmodule Mv.Mailer do
@moduledoc """
Swoosh mailer for transactional emails.
Use `mail_from/0` for the configured sender address (join confirmation,
user confirmation, password reset).
"""
use Swoosh.Mailer, otp_app: :mv
@doc """
Returns the configured "from" address for transactional emails.
Configure in config.exs or runtime.exs as `config :mv, :mail_from, {name, email}`.
Default: `{"Mila", "noreply@example.com"}`.
"""
def mail_from do
Application.get_env(:mv, :mail_from, {"Mila", "noreply@example.com"})
end
@doc """
Sends a test email to the given address. Used from Global Settings SMTP section.
Returns `{:ok, email}` on success, `{:error, reason}` on failure (e.g. invalid address,
SMTP not configured, connection error). Stub: always returns error until implemented.
"""
@spec send_test_email(String.t()) :: {:ok, Swoosh.Email.t()} | {:error, term()}
def send_test_email(_to_email) do
{:error, :not_implemented}
end
end