StrawHat.Mailer v0.4.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
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
, html
and text
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"}
Recipient or list of recipients of the email.
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_or_template_schema, data \\ %{})
View Source
with_template(Swoosh.Email.t(), StrawHat.Mailer.Schema.Template.t() | String.t(), map()) :: {:ok, Swoosh.Email.t()} | {:error, StrawHat.Error.t()}
Add subject
, html
and text
to the Email using a template.