philomena/lib/philomena/mailer.ex

20 lines
511 B
Elixir
Raw Normal View History

defmodule Philomena.Mailer do
2024-06-02 00:49:01 -04:00
use Swoosh.Mailer, otp_app: :philomena
2024-12-10 15:22:22 -05:00
alias Swoosh.Email
2024-06-02 00:49:01 -04:00
2024-12-10 15:22:22 -05:00
@spec deliver_later(Email.t()) :: {:ok, Email.t()}
2024-06-02 00:49:01 -04:00
def deliver_later(mail) do
Task.Supervisor.start_child(Philomena.AsyncEmailSupervisor, fn -> deliver(mail) end)
{:ok, mail}
end
2024-12-10 15:22:22 -05:00
@spec format_message(Email.t()) :: Email.t()
def format_message(mail) do
Email.from(mail, {"noreply", mailer_address()})
2024-12-10 15:22:22 -05:00
end
defp mailer_address do
Application.get_env(:philomena, :mailer_address)
end
2020-01-10 23:20:19 -05:00
end