View Source Swoosh.Adapters.Mailjet (Swoosh v1.8.1)
An adapter that sends email using the Mailjet API.
For reference: Mailjet API docs
dependency
Dependency
Mailjet adapter requires Plug
to work properly.
example
Example
# config/config.exs
config :sample, Sample.Mailer,
adapter: Swoosh.Adapters.Mailjet,
api_key: "my-api-key",
secret: "my-secret-key"
# lib/sample/mailer.ex
defmodule Sample.Mailer do
use Swoosh.Mailer, otp_app: :sample
end
using-with-provider-options
Using with provider options
import Swoosh.Email
new()
|> from({"Billi Wang", "billi_wang@example.com"})
|> to({"Nai Nai", "nainai@example.com"})
|> reply_to("a24@example.com")
|> cc({"Haiyan Wang", "haiyan_wang@example.com"})
|> cc("lujian@example.com")
|> bcc({"Hao Hao", "haohao@example.com"})
|> bcc("aiko@example.com")
|> subject("Hello, Nai Nai!")
|> html_body("<h1>Hello</h1>")
|> text_body("Hello")
|> put_provider_option(:template_id, 123)
|> put_provider_option(:template_error_deliver, true)
|> put_provider_option(:template_error_reporting, "developer@example.com")
|> put_provider_option(:variables, %{firstname: "lulu", lastname: "wang"})
provider-options
Provider options
:template_id
(integer) -TemplateID
, unique template id of the template to be used as email content:template_error_deliver
(boolean) -TemplateErrorDeliver
, send even if error in template iftrue
, otherwise stop email delivery immediately upon error:template_error_reporting
(string | tuple | map) -TemplateErrorReporting
, email address or a tuple of name and email address of a recipient to send a carbon copy upon error:variables
(map) -Variables
, custom key-value variable for the email content
Link to this section Summary
Functions
Callback implementation for Swoosh.Adapter.validate_config/1
.
Callback implementation for Swoosh.Adapter.validate_dependency/0
.
Link to this section Functions
Callback implementation for Swoosh.Adapter.validate_config/1
.
Callback implementation for Swoosh.Adapter.validate_dependency/0
.