View Source Swoosh.Adapter behaviour (Swoosh v1.17.3)

Specification of the email delivery adapter.

Summary

Callbacks

Delivers an email with the given config.

Delivers multiple emails with the given config in one request. Some email providers allow multiple messages to be sent in one HTTP request, for example Mailjet and Postmark allow this. Check your provider's documentation to see if that is possible, and see the adapter you use to find out whether it has been implemented.

Types

config()

@type config() :: Keyword.t()

email()

@type email() :: Swoosh.Email.t()

t()

@type t() :: module()

Callbacks

deliver(email, config)

@callback deliver(email(), config()) :: {:ok, term()} | {:error, term()}

Delivers an email with the given config.

deliver_many(list, config)

(optional)
@callback deliver_many([email()], config()) :: {:ok, [term()]} | {:error, term()}

Delivers multiple emails with the given config in one request. Some email providers allow multiple messages to be sent in one HTTP request, for example Mailjet and Postmark allow this. Check your provider's documentation to see if that is possible, and see the adapter you use to find out whether it has been implemented.

validate_config(config)

@callback validate_config(config()) :: :ok | no_return()

validate_dependency()

(optional)
@callback validate_dependency() :: :ok | [module() | {atom(), module()}]

Functions

validate_config(required_config, config)

@spec validate_config([atom()], Keyword.t()) :: :ok | no_return()

validate_dependency(required_deps)

@spec validate_dependency([module() | {atom(), module()}]) ::
  :ok | {:error, [module() | {:atom | module()}]}