helf v0.0.1 HELF.Mailer

Provides a way for sending emails with a list of Bamboo mailers.

It will try to send the email using the first available mailer, and then fallback to the next whenever the current one fails.

Before using the module, you should configure the list of mailers, this is what it should looks like:

config :helf, HELF.Mailer,
  mailers: [HELM.Mailer.MailGun, HELM.Mailer.Maldrill],
  default_sender: "sender@config.com"

The default sender is completely optional.

Link to this section Summary

Functions

Awaits until email is sent, will raise RuntimeError on timeout

Sets the email sender

Sets the html body of the email

Creates a new empty email, see new/1 for composing emails using the params

Creates and composes a new email using the params

Sends the email, optionally accepts a mailers keyword

Sends the email from another processs, optionally accepts notify and mailers keywords

Sets the email subject

Sets the text body of the email

Sets the email recipient

Awaits until email is sent, yields nil on timeout

Link to this section Types

Link to this type params()
params() :: [from: String.t, to: String.t, subject: String.t, text: String.t, html: String.t]

Link to this section Functions

Link to this function await(async_email, timeout \\ 5000)
await(HELF.Mailer.AsyncEmail.t, timeout :: non_neg_integer) ::
  {:ok, HELF.Mailer.SentEmail.t} |
  {:error, email}

Awaits until email is sent, will raise RuntimeError on timeout.

Link to this function from(email, sender)
from(email, sender :: String.t) :: email

Sets the email sender.

Link to this function html(email, html)
html(email, html :: String.t) :: email

Sets the html body of the email.

Creates a new empty email, see new/1 for composing emails using the params.

Link to this function new(parameters)
new(params) :: email

Creates and composes a new email using the params.

Link to this function send(email, params \\ [])
send(email, params :: [{:mailers, [module, ...]}]) ::
  {:ok, HELF.Mailer.SentEmail.t} |
  {:error, email} |
  {:error, :internal_error}

Sends the email, optionally accepts a mailers keyword.

Link to this function send_async(email, params \\ [])
send_async(email, params :: [notify: boolean, mailers: [module, ...]]) :: HELF.Mailer.AsyncEmail.t

Sends the email from another processs, optionally accepts notify and mailers keywords.

To use await and yield methods, set the notify keyword to true.

Link to this function subject(email, subject)
subject(email, subject :: String.t) :: email

Sets the email subject.

Link to this function text(email, text)
text(email, text :: String.t) :: email

Sets the text body of the email.

Link to this function to(email, receiver)
to(email, receiver :: String.t) :: email

Sets the email recipient.

Link to this function yield(async_email, timeout \\ 5000)
yield(HELF.Mailer.AsyncEmail.t, timeout :: non_neg_integer) ::
  {:ok, HELF.Mailer.SentEmail.t} |
  {:error, email} |
  nil

Awaits until email is sent, yields nil on timeout.