2019-11-15 03:40:35 +01:00
|
|
|
defmodule PhilomenaWeb.PowMailer do
|
|
|
|
use Pow.Phoenix.Mailer
|
|
|
|
alias PhilomenaWeb.Mailer
|
|
|
|
alias Philomena.Users.User
|
|
|
|
import Bamboo.Email
|
|
|
|
|
2020-01-11 05:20:19 +01:00
|
|
|
def cast(%{
|
|
|
|
user: %User{email: email},
|
|
|
|
subject: subject,
|
|
|
|
text: text,
|
|
|
|
html: html,
|
|
|
|
assigns: _assigns
|
|
|
|
}) do
|
2019-11-15 03:40:35 +01:00
|
|
|
# Build email struct to be used in `process/1`
|
|
|
|
new_email(
|
|
|
|
to: email,
|
|
|
|
from: Application.get_env(:philomena, :mailer_address),
|
|
|
|
subject: subject,
|
|
|
|
text_body: text,
|
|
|
|
html_body: html
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def process(email) do
|
|
|
|
email
|
|
|
|
|> Mailer.deliver_later()
|
|
|
|
end
|
2020-01-11 05:20:19 +01:00
|
|
|
end
|