An adapter that sends email to a self-hosted Mailpit server via its HTTP API.
For reference: Mailpit 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.
Example
# config/config.exs
config :sample, Sample.Mailer,
adapter: Swoosh.Adapters.Mailpit,
base_url: "https://mailpit.example.com",
api_key: "YnJ...0Rw==" # optional, for Basic Auth
# lib/sample/mailer.ex
defmodule Sample.Mailer do
use Swoosh.Mailer, otp_app: :sample
endUsing with provider options
import Swoosh.Email
new()
|> from({"Raife Hastings", "raife@example.com"})
|> to({"Jed Haverford", "jed@example.com"})
|> reply_to("raife.hastings@example.com")
|> cc("eliza@example.com")
|> cc({"Jules Landry", "jules@example.com"})
|> bcc("james.reece@example.com")
|> bcc({"Ben Edwards", "ben@example.com"})
|> subject("Hello there")
|> html_body("<h1>Hello</h1>")
|> text_body("Hello")
|> put_provider_option(:tags, ["welcome", "transactional"])Provider Options
Supported provider options are the following:
Inserted into request body
:tags(list of strings) - Mailpit tags
Summary
Functions
Callback implementation for Swoosh.Adapter.deliver/2.
Callback implementation for Swoosh.Adapter.validate_config/1.
Callback implementation for Swoosh.Adapter.validate_dependency/0.
Functions
Callback implementation for Swoosh.Adapter.deliver/2.
Callback implementation for Swoosh.Adapter.validate_config/1.
Callback implementation for Swoosh.Adapter.validate_dependency/0.