Zoonk.Mailer (Zoonk v0.1.0-dev)

View Source

Provides email sending functionality.

You can use Zoonk.Mailer.send_email/3 to send emails, such as account veritification, notifications, and more.

Summary

Functions

Delivers an email.

Delivers an email, raises on error.

Delivers a list of emails.

Sends an email with the given recipient, subject, and body.

Functions

deliver(email, config \\ [])

@spec deliver(Swoosh.Email.t(), Keyword.t()) :: {:ok, term()} | {:error, term()}

Delivers an email.

If the email is delivered it returns an {:ok, result} tuple. If it fails, returns an {:error, error} tuple.

deliver!(email, config \\ [])

@spec deliver!(Swoosh.Email.t(), Keyword.t()) :: term() | no_return()

Delivers an email, raises on error.

If the email is delivered, it returns the result. If it fails, it raises a DeliveryError.

deliver_many(emails, config \\ [])

@spec 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()
    }
  ],
  Keyword.t()
) :: {:ok, term()} | {:error, term()}

Delivers a list of emails.

It accepts a list of %Swoosh.Email{} as its first parameter.

send_email(recipient, subject, body)

Sends an email with the given recipient, subject, and body.

Parameters

  • recipient (string): The email address of the recipient.
  • subject (string): The subject of the email.
  • body (string): The plain text content of the email.

Returns

  • {:ok, email} if the email was successfully sent.
  • An error tuple if the email delivery fails.