StrawHat.Mailer v2.0.0 StrawHat.Mailer.Emails View Source
Adds capability to create emails using templates.
from = {"ACME", "noreply@acme.com"}
to = {"Straw Hat Team", "some_email@acme.com"}
data = %{
"confirmation_token" => "12345"
}
email = StrawHat.Mailer.Email.new(from, to)
{:ok, email} = StrawHat.Mailer.Email.with_template(MyRepo, email, "confirmation_email", data)
StrawHat.Mailer.deliver_later(email)
All your templates will receive the same shape of data which you could use
mustache syntax for using it, read about t:StrawHat.Mailer.Email.template_data/0
.
Link to this section Summary
Types
The tuple is compose by the name and email
You would use the data as mustache syntax does it using brackets
Recipient or list of recipients of the email
Functions
Creates 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
Adds subject
, html
and text
to the Email using a template
Adds subject
, html
and text
to the Email using a template
Link to this section Types
address() View Source
The tuple is compose by the name and email.
Example:
{"Straw Hat Team", "straw_hat_team@straw_hat.com"}
template_data() View Source
You would use the data as mustache syntax does it using brackets.
The partials
key will whole all the partials of your template using
name as the key
so you will be able to use it as {{{partials.PARTIAL_NAME}}}
.
Notice I am using triple brackets and that is because probably you want to escape the output.
Recipient or list of recipients of the email.
Link to this section Functions
new(from, to, opts \\ [])
View Source
new(address(), to(), keyword()) :: Swoosh.Email.t()
new(address(), to(), keyword()) :: Swoosh.Email.t()
Creates 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
.
with_template(email, template, data)
View Source
with_template(Swoosh.Email.t(), StrawHat.Mailer.Template.t(), map()) ::
{:ok, Swoosh.Email.t()} | {:error, Error.t()}
with_template(Swoosh.Email.t(), StrawHat.Mailer.Template.t(), map()) :: {:ok, Swoosh.Email.t()} | {:error, Error.t()}
Adds subject
, html
and text
to the Email using a template.
with_template(repo, email, template_name, data)
View Source
with_template(Ecto.Repo.t(), Swoosh.Email.t(), String.t(), map()) ::
{:ok, Swoosh.Email.t()} | {:error, Error.t()}
with_template(Ecto.Repo.t(), Swoosh.Email.t(), String.t(), map()) :: {:ok, Swoosh.Email.t()} | {:error, Error.t()}
Adds subject
, html
and text
to the Email using a template.