View Source Swoosh.Adapters.Mailjet (Swoosh v1.17.2)

An adapter that sends email using the Mailjet API.

For reference: Mailjet API docs

This adapter requires an API Client. Swoosh comes with Hackney, Finch and Req out of the box. See the installation section for details.

Dependency

Mailjet adapter requires Plug to work properly.

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

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

  • :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 if true, 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

Summary

Functions

Link to this function

deliver(email, config \\ [])

View Source

Callback implementation for Swoosh.Adapter.deliver/2.

Link to this function

deliver_many(emails, config \\ [])

View Source

Callback implementation for Swoosh.Adapter.deliver_many/2.

Callback implementation for Swoosh.Adapter.validate_config/1.

Callback implementation for Swoosh.Adapter.validate_dependency/0.