Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 735 Bytes

SWOOSH_MAILER.md

File metadata and controls

29 lines (22 loc) · 735 Bytes

Swoosh mailer

You can easily set up the mailer to use Swoosh.

First be sure that you've set up and configured Swoosh with your app. Then set up your WEB_PATH/pow_mailer.ex file like so:

defmodule MyAppWeb.PowMailer do
  use Pow.Phoenix.Mailer
  use Swoosh.Mailer, otp_app: :my_app

  import Swoosh.Email

  def cast(%{user: user, subject: subject, text: text, html: html}) do
    %Swoosh.Email{}
    |> to({"", user.email})
    |> from({"My App", "[email protected]"})
    |> subject(subject)
    |> html_body(html)
    |> text_body(text)
  end

  def process(email) do
    deliver(email)
  end
end

Remember to add mailer_backend: MyAppWeb.PowMailer to the Pow configuration.