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

Specification of the email delivery adapter.

Link to this section 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 allow this. Check your provider's documentation to see if that is possible.

Link to this section Types

@type config() :: Keyword.t()
@type email() :: Email.t()
@type t() :: module()

Link to this section Callbacks

Link to this callback

deliver(%Swoosh.Email{}, config)

View Source
@callback deliver(
  %Swoosh.Email{
    assigns: term(),
    attachments: term(),
    bcc: term(),
    cc: term(),
    from: term(),
    headers: term(),
    html_body: term(),
    private: term(),
    provider_options: term(),
    reply_to: term(),
    subject: term(),
    text_body: term(),
    to: term()
  },
  config()
) :: {:ok, term()} | {:error, term()}

Delivers an email with the given config.

Link to this callback

deliver_many(list, config)

View Source (optional)
@callback deliver_many(
  [
    %Swoosh.Email{
      assigns: term(),
      attachments: term(),
      bcc: term(),
      cc: term(),
      from: term(),
      headers: term(),
      html_body: term(),
      private: term(),
      provider_options: term(),
      reply_to: term(),
      subject: term(),
      text_body: term(),
      to: term()
    }
  ],
  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 allow this. Check your provider's documentation to see if that is possible.

@callback validate_config(config()) :: :ok | no_return()
Link to this callback

validate_dependency()

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

Link to this section Functions

Link to this function

validate_config(required_config, config)

View Source
@spec validate_config([atom()], Keyword.t()) :: :ok | no_return()
Link to this function

validate_dependency(required_deps)

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