StrawHat.Mailer v0.2.1 StrawHat.Mailer.Email View Source

Add capability to create emails using templates.

token = get_token()
from = {"ACME", "noreply@acme.com"}
to = {"Straw Hat Team", "some_email@acme.com"}
data = %{
  confirmation_token: token
}

{:ok, email} =
  from
  |> StrawHat.Mailer.Email.new(to)
  |> StrawHat.Mailer.Email.with_template("welcome", data)

StrawHat.Mailer.deliver(email)

Link to this section Summary

Types

The tuple is compose by the name and email

Functions

Create a Swoosh.Email struct. It use Swoosh.Email.new/1 so you can check the Swoosh documentation, the only different is this one force you to pass from and to as paramters rather than inside the opts

Add subject and html_body to the Email using a template

Link to this section Types

The tuple is compose by the name and email.

Example: {"Straw Hat Team", "straw_hat_team@straw_hat.com"}

Link to this section Functions

Link to this function new(from, to, opts \\ []) View Source
new(address(), to(), keyword()) :: Swoosh.Email.t()

Create a Swoosh.Email struct. It use Swoosh.Email.new/1 so you can check the Swoosh documentation, the only different is this one force you to pass from and to as paramters rather than inside the opts.

Link to this function with_template(email, template_name, data) View Source
with_template(Swoosh.Email.t(), String.t(), map()) :: Swoosh.Email.t()

Add subject and html_body to the Email using a template.