View Source Yugo (Yugo v0.2.0)

Auxiliary functions for Yugo.

Link to this section Summary

Types

A body can be either "onepart" or "multipart".

An email message sent to a subscribed process.

e.g. "text/html", "image/png", "text/plain", etc.

Functions

Subscribes the calling process to the Client named by client_name.

Unsubscribes the calling process from the specified Client.

Link to this section Types

@type address() :: String.t()
@type body() :: {mime_type(), binary()} | [body()]

A body can be either "onepart" or "multipart".

A "onepart" body is a tuple in the form {mime_type, content}, where mime_type is a mime_type, and content is a binary.

A "multipart" body consists of a list of "parts". Each part is itself another body.

@type email() :: %{
  bcc: [address()],
  body: body(),
  cc: [address()],
  date: DateTime.t(),
  flags: [flag()],
  in_reply_to: nil | String.t(),
  message_id: nil | String.t(),
  reply_to: [address()],
  sender: [address()],
  subject: nil | String.t(),
  to: [address()]
}

An email message sent to a subscribed process.

@type flag() :: :seen | :answered | :flagged | :draft | :deleted
@type mime_type() :: String.t()

e.g. "text/html", "image/png", "text/plain", etc.

For more, see this list of MIME types.

Link to this section Functions

Link to this function

subscribe(client_name, filter \\ Filter.all())

View Source
@spec subscribe(Yugo.Client.name(), Yugo.Filter.t()) :: :ok

Subscribes the calling process to the Client named by client_name.

When you subscribe to a client, your process will be notified about new emails via a message in the form {:email, client, message}, where client is the name of the client that is notifying you, and message is the email. See the email type for the structure of the message field.

You may also pass an optional Filter as the second argument to match what emails you want to be notified about. If you do not pass a filter, it defaults to Filter.all, which allows all emails to pass through.

Link to this function

unsubscribe(client_name)

View Source
@spec unsubscribe(Yugo.Client.name()) :: :ok

Unsubscribes the calling process from the specified Client.

This will unsubscribe the calling process from all messages from the client, regardless of how many separate times you subscribed